若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”);}
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”);}
举一反三
- 若有以下定义,则正确的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”); }
- 若有定义:floatx=1.5;inta=1,b=3,c=2;则正确的switch语句是( )。 A: switch(a+b) <br> { case 1:printf("*\n"); <br> case 2+1:printf("**\n");} B: switch((int)x);<br>{case1:printf("*\n");<br>case2:printf("**\n");} C: switch(x)<br>{case1.0:printf("*\n");<br>case2.0:printf("**\n");} D: switch(a+b)<br>{case1:printf("*\n");<br>casec:printf("**\n");}
- 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,请问运行结果为:
- 若有以下定义:float x;int a,b;则正确的switch语句是( ) A: switch(x){case 1.0:printf("* ");case 2.0:printf("** ");} B: switch(x){case 1,2:printf("* ");case 3:printf("** ");} C: switch(a+b){case 1:printf("* ");case 1+2:printf("** ");} D: switch(a){case b<1:printf("* ");case b>2:printf("** ");}