问题 单项选择题

有以下程序: #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

答案

参考答案:C

解析: 本题中没有使用break终止switch语句的执行,当k为’0’时,执行完case ’0’后的输出后将继续执行case ’1’后的输出;当k为’1’时,执行case ’1’后的输出。

填空题
单项选择题