有以下程序 #inclUde main() {int x=1。y=0; if(!x)y++; else if(x==0) if(x)y+=2; else y+=3; . prin

admin2011-04-29  33

问题 有以下程序
    #inclUde
    main()
    {int x=1。y=0;
    if(!x)y++;
    else if(x==0)  
    if(x)y+=2;
    else y+=3;    .
    printf(“%d\n”,y);
    }
    程序运行后的输出结果是

选项 A、3
B、2
C、1
D、0

答案D

解析 本题主要考查的知识点为if语句的嵌套.变量x的值(为1。既不满址表达式!x为真.也不满足表达式x==0.故不执行if语句,而直接执行printf函数输出y的值0。   
转载请注明原文地址:https://kaotiyun.com/show/UPPp777K
0

最新回复(0)