有以下程序: #include <stdio.h> main() { char k; int i; for(i=1;i<3;i++) { scanf("%c",&k); switch(k)

admin2009-01-15  18

问题 有以下程序:    #include  <stdio.h>    main()    {  char k; int i;       for(i=1;i<3;i++)       {  scanf("%c",&k);          switch(k)          {  case ’0’: printf("another\n");             case ’1’: printf("number\n");          }       {    }    程序运行时,从键盘输入:01<回车>,程序执行后的输出结果是(    )。

选项 A、another    number
B、another    number    another
C、another    number
D、number    number

答案4

解析 本题中没有使用break终止switch语句的执行,当k为’0’时,执行完case ’0’后的输出后将继续执行case ’1’后的输出;当k为’1’时,执行case ’1’后的输出。
转载请注明原文地址:https://kaotiyun.com/show/jpHp777K
0

相关试题推荐
最新回复(0)