有以下程序  main( )  { char k;   int   l;    for(i=1;i<3;i++)      { scanf(“%c”,&k);        switch(k)        {  case ‘0’:  printf(“an

admin2006-03-15  9

问题 有以下程序  main( )  { char k;   int   l;    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   number
D、number    number

答案A

解析 在本题中,for循环共有两次,因此输出结果为两行;而且在scanf语句中,如果输入的数据多于scanf要求输入的数据,则多余的数据将留在缓冲区作为下一次输入操作的输人数据。
转载请注明原文地址:https://kaotiyun.com/show/DaHp777K
0

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