• 2022-07-26
    若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”);}
  • D

    举一反三

    内容

    • 0

      #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”); } } 运行结果为( )

    • 1

      若有以下定义: float x;int a,b; 则正确的switch 语句是( )。 A: switch(x) { case 1.0:printf(&quot;* &quot;); case 2.0:printf(&quot;** &quot;); } B: switch(x){ case 1,2:printf(&quot;* &quot;); case 3:printf(&quot;** &quot;); } C: switch (a+b) { case 1:printf(&quot; &quot;); case 1+2:printf(&quot;** &quot;); } D: switch (a+b);{ case 1:printf(.&quot;* &quot;); case 2:printf(&quot;** &quot;); }

    • 2

      若有以下定义:float x; int a,b; 则正确的switch语句是 。 A: switch(x) { case 1.0: printf(&quot;* &quot;); case 2.0: printf(&quot;** &quot;); } B: switch(x) { case 1,2: printf(&quot;* &quot;); case 3: printf(&quot;** &quot;); } C: switch(a+b) { case 1: printf(&quot;* &quot;); case 1+2: printf(&quot;** &quot;); } D: switch(a+b); { case 1: printf(&quot;* &quot;); case 2: printf(&quot;** &quot;); }

    • 3

      执行语句序列 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,则屏幕显示【 】

    • 4

      中国大学MOOC: 以下程序输出的结果是()# include <stdio.h>int main(){ int a = 4; switch(a ) { case 0: printf("this is 0\n"); break; case 1: printf("this is 1\n"); break; case 2: printf("this is 2\n"); break; default: printf("this is default\n"); } return 0;