switch(a){ case 1:printf(“Monday\n"); case 2:printf("Tuesday\n"); case 3:printf(“Wednesday\n"); case 4:printf("Thursday\n"); case 5:printf("Friday\n");break; case 6:printf("Saturday\n"); case 7:printf("Sunday\n"); } 若a的值为6,请问运行结果为:
举一反三
- 若a,b均是整型变量,正确的switch语句是( )。 A: switch(a){case 1.0: printf(“i\n”);case 2: printf(“you\n”); ”);} B: switch(a){case b: printf(“i\n”);case 1: printf(“you\n”);} C: switch(a+b){case 1: printf(“i\n”);case 2*a: printf(“you\n”);} D: switch(a+b){case 1: printf(“i\n”);case 2: printf(“you\n”);}
- #include main()_ { char grade=’C’; switch(grade) { case ‘A’: printf(“90-100\n”); case ‘B’: printf(“80-90\n”); case ‘C’: printf(“70-80\n”); case ‘D’: printf(“60-70\n”); break; case ‘E’: printf(“<60\n”); default : printf(“error!\n”); } } 运行结果为( )
- 若有以下定义,则正确的switch语句是______。float x;int a,b; A: switch(x) B: case 1.0:printf("*\n"); C: csse 2.0:printf("**\n"); D: switch(x) E: case 1,2:printf("*\n"); F: case 3:printf("**\n"); G: switch(a+b) H: case 1:printf("\n"); I: case 1+2:printf("**\n"); J: switch(a+b); K: case 1:printf("*\n"); L: case 2:printf("**\n");
- 若有float x; int a,b; ,下面四条switch语句中正确的有( )条。 switch(x) { case x=1.0: printf(“Y”); case x=2.0: printf(“N”); } switch(a) { case a=1: printf(“Y”); case a=2: printf(“N”); } switch(b) { case b==1: printf(“Y”); case b==2: printf(“N”); } switch(x) { case 1.0: printf(“Y”); case 2.0: printf(“N”); }
- 执行语句序列 int n; scanf("%d",&n); switch(n) { case 1: printf("%c ",'1'); case 3: case 4: printf("%c ",'2');; break; default: printf("%c ",'3'); } 时,若键盘输入1,则屏幕显示【 】