5-5、有以下程序段intk=0;while(k=1)k++;while循环执行的次数是______。
A. 无限次
B. 有语法错,不能执行
C. 一次也不执行
D. 执行1次
查看答案
5-6、以下程序片段执行后,sum的值是______。inti,sum;for(i=1;i<6;i++)sum+=i;printf(“%d\n”,sum);
A. 15
B. 14
C. 不确定
D. 0
5-8、有以下程序片段,执行后输出的结果是________。for(i=0;i<3;i++)switch(i){case1:printf(“%d”,i);case2:printf(“%d”,i);default:printf(“%d”,i);}
A. 011122
B. 012
C. 012020
D. 120
5-9、有以下程序片段,从键盘输入:01↙,程序执行后的输出结果是______。for(i=1;i<3;i++){scanf(“%c”,&k);switch(k){case‘0’:printf(“another”);case‘1’:printf(“number\n”);}}
A. anothernumber
B. anothernumberanother
C. anothernumbernumber
D. numbernumber
5-12、下面程序段的运行结果是__________。a=1;b=2;c=2;while(a
A. 1,2,0
B. 2,1,0
C. 1,2,1
D. 2,1,1