4.阅读以下程序,写出程序运行结果。
#include<stdio.h>
void main()
char char='B';
switch()
I
case'A'ːprintf("it is A\n");
case'B':printf("it is B\n");
case'C':printf("it is C\n");
default:printf("other\n");
)
)
什么都不执行,swtch值就没传
【如果题主的程序没有笔误】
运行结果是报错,主要有以下错误:
【如果题主的程序有笔误,排除上述报错】
因为每个case都没有break,在匹配了case 'B'之后会继续往下面的case走
运行结果是:
it is B
it is C
other