问题 填空题

下列程序段的输出结果是______。
int n=’c’;
switch(n++)
default:printf("error");break;
case ’a’: printf("good");break;
case ’c’: printf("morning");
case ’d’: printf("class");

答案

参考答案:morningclass

解析: 本题考查了两个知识点:①“++,--”运算后缀形式是先使用变量原来的值,使用完后再使其增1或减1;②在switch语句中,当n=’c’时,执行“case ’c’”,输出morning;因为此句中没有break语句,因此接着执行“case ’d’:”,输出class,最终输出结果为morningclass。

填空题
多项选择题