【单选题】关于以下程序段,下面的说法正确的是() char result; scanf ("%c",result); switch(result) { case 'A': case 'B': printf ("Good!n"); break; case 'E': printf ("Bad!n"); default: printf ("Error!n"); }A.执行程序段后,输入a或者b,都将输出Good!B.执行程序段后,输入A或者B或者C,都将输出Good!C.执行程序段后,输入E,将输出Bad!,然后结束D.执行程序段后,输入C,将输出 Error!

【单选题】关于以下程序段,下面的说法正确的是() char result; scanf ("%c",&result); switch(result) { case 'A': case 'B': printf ("Good!n"); break; case 'E': printf ("Bad!n"); default: printf ("Error!n"); }

A.执行程序段后,输入a或者b,都将输出Good!

B.执行程序段后,输入A或者B或者C,都将输出Good!

C.执行程序段后,输入E,将输出Bad!,然后结束

D.执行程序段后,输入C,将输出 Error!


参考答案和解析
知识既具有非排他性,又具有非竞争性。

相关考题:

(33)有以下程序段int i,n;for(i=0;i8;i++){ n=rand()%5;switch (n){ case 1:case 3:printf("%d\n",n); break;case 2:case 4:printf("%d\n",n); continue;case 0:exit(0);}printf("%d\n",n);}以下关于程序段执行情况的叙述,正确的是A)for循环语句固定执行8次B)当产生的随机数n为4时结束循环操作C)当产生的随机数n为1和2时不做任何操作D)当产生的随机数n为0时结束程序运行

有以下程序main( ){ int k=5,n=0;do{ switch(k){ case 1: case3: n+=1; k--; break;default;n=0;k--;case 2: case4: n+=2;k--; break;}printf("%d",n);}while(k0 n5);}程序运行后的输出结果是A)235B)0235C)02356D)2356

以下程序的运行结果是 【 9 】 。main( ){ int a=2,b=7,c=5;switch(a0){ case 1:switch(b0){ case 1: printf ("@"); break;case 2: printf("!"); break;}case 0: switch(c==5){ case 0 : printf (" * "); break;case 1 : printf(" # "); break;case 2: printf(" $ "); break;}default : printf("");}printf("\n");}

若有定义 : float x=1.5; int a=1,b=3,c=2; 则正确的 switch 语句是A)switch(x){ case 1.0: printf("*\n");case 2.0: printf("**\n");}B)switch((int)x);{ case 1: printf("*\n");case 2: printf("**\n");}C)switch(a+b){ case 1: printf("*\n");case 2+1: printf("**\n");}D)switch(a+b){ case 1: printf("*\n");case c: printf("**\n");}

有以下程序:void main(){ int k=0,n=0; while(k5) { switch(k) { default: break; case 1:n+=k; case 2: case 3:n+=k; } k++;}printf("%d\n",n); } 程序运行后的输出结果是( )。A)0 B)4C)6 D)7

有以下程序: main() {int k=5,n=0; while(k>0) {switch(k) {default:break; case 1:n+=k; case 2: case 3:n+=k; } k--; } printf("%d\n",n); } 程序运行后的输出结果是( )。A.0B.4C.6D.7

若有定义:float x=1.5;int a=1,b=3,c=2;,则正确的switch语句是A.switch(x) {case 1.0:printf("*\n"); case 2.0:printf("**\n");}B.switch((int)x); {case 1:printf("*\n"); case 2:printf("**\n");}C.switch(a+B) {case 1:printf("*\n"); case 2+1:printf("**\n");}D.switch(a+B) {case 1:printf("*\n"); case c:printf("**\n");}

有以下程序段:int i,n;for(i=0;i8;i++) {n=rand( )%5;switch(n){case l:case 3:printf(8;i++){n=rand( )%5;switch(n){case l:case 3:printf(%d\n,n);break;case 2:case 4:print?(%d\n,n);continue;case( ):exit(0);}printf(%d\n,n);}以下关于程序段执行情况的叙述,正确的是( )。A.for循环语句固定执行8次B.当产生的随机数n为4时结束循环操作C.当产生的随机数n为1和2时不做任何操作D.当产生的随机数n为0时结束程序运行

运行下面程序时,从键盘输入字母H,则输出结果是#includestdio.hmain(){ char ch;ch=getchar();switch(ch){case ′H′:printf("Hello!\n");case ′G′:printf("Good morning!\n");default:printf("Bye_Bye!\n");}}A.Hello!B.Hello! Good Moring!C.Hello! Good morning! Bye_Bye!D.Hello! Bye_Bye!

有以下程序 main() { int k=5,n=0; do { switch(k) { case 1: case 3:n+=1;k--;break; default:n=0;k--; case 2: case 4:n+=2;k--;break; } printf("%d",n); }while(k>0n<5); } 程序运行后的输出结果是A.235B.235C.2356D.2356

以下程序段的运行结果是( )。 include main() {int x=2,y=1: switch(x) {case 1: switch 以下程序段的运行结果是( )。 include<stdio.h> main() {int x=2,y=1: switch(x) {case 1: switch(y) {case 0:printf("x=2,y=1\n");break; case 1:printf("y=1\n");break; } case 2:printf("x=2\n"); } }

*((int *)pval)/=2; //我想问一下,这个语法怎么理解,太复杂了 具体代码如下。 #include "stdio.h"void half(void *pval,char type);main(){ int i=20; long l=100000; float ff=12.456; double d=123.044444; printf("%d\n",i); printf("%ld\n",l); printf("%f\n",ff); printf("%lf\n",d); half( half( half( half( printf("\n%d",i); printf("\n%ld",l); printf("\n%f",ff); printf("\n%lf",d); return 0; }void half(void *pval,char type){ switch(type) { case 'i': { *((int *)pval)/=2; //我想问一下,这个语法怎么理解,太复杂了 break; } case 'l': { *((long *)pval)/=2; break; } case 'ff': { *((float *)pval)/=2; break; } case 'd': { *((double *)pval)/=2; break; } } }

以下程序的运行结果是( )。main()(int a=2,b=7,c=5;switch(a>0){case 1:switch(b<0){case 1:switch(");break;case 2:printf("!");break;}case 0:switch(c==5){case 0:printf("*");break;case 1:printf("");break;case 2:printf("$");break;}default:printf ("&");}printf("\n");}

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

若有以下定义:float x;int a,b; 则错误的switch语句是________。 A. switch(x){case 1.0:printf("*\n"); case 2.0:printf("*\n"); }B. switch(a){case 1:printf("*\n");case 2:printf("*\n"); }C. switch(a+b) {case 1:printf("*\n"); case 1+2:printf("*\n"); }D. switch(a+b);{case 1:printf("*\n");case 2:printf("*\n"); }

设有说明:int a=1,b=0;,则执行以下语句的输出结果是______。 switch(a) {case 1: switch(b) {case 0:printf("**0**\n");break; case 1:printf("**1*\n");break; } case 2:printf("**2**\n");break; }A.**0**B.**0** **2**C.**0** **1** **2**D.switch语句中存在语法错误

有下列程序: main() {int k=5,n=0; do {switch(k) {case 1: case 3:n+=1;k--;break; default:n=0;k--; case 2: case 4;n+=2;k--;break; } printf("%d",n); }while(k>On<5); } 程序运行后的输出结果是( )。A.235B.0235C.02356D.2356

请补充main函数,该函数的功能是:从键盘输入只有两个整数参与运算的一个四则运算式,然后计算出它的值。注意数字全部为正整数。例如,输入308*28,结果为8624.000000。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:include<stdio, h>main ( ){int a=0, b=0, flag=l, fg=l;float result;char *p, ch;char str[10];clrscr ();printf("\n Input a string \n");gets (str);p=str;while (*p){if (*p>='0' *p<='9' flag==l )a=【 】;elseif (fg){ch=*p;flag=2;fg=0;}if (*p>='0 ' *p<='9' flag==2)b=【 】;p++;}switch(【 】){case '+': result=a+b;break;case '-': result=a-b;break;case '*' :result=a*b;break;case '/' :result= (float) a/b;break;printf ("\nresult=%f", result);}

有以下程序段int i,n;for(i=0;i8;i++){n=rand()%5;switch(n){case 1:case 3:printf(“%d\n”,n);break;case 2.case 4:printf(“%d\n”,n);continue;case 0:exit(0);}printf(“%d\n”,n);}以下关于程序段执行情况的叙述,正确的是A.for循环语句固定执行8次B.当产生的随机数n为4时结束循环操作C.当产生的随机数n为1和2时不做任何操作D.当产生的随机数n为0时结束程序运行

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

若有定义float x=1.5;int a=1,b=3,c=2;,则正确的switch语句是A.swimh(x) {case 1.0:printf("*\n"); case 2.0:printf("**\n");}B.switch((int)x); {case 1:printf("*\n"); case 2:printf("**\n");}C.switch(a+D. {case 1:pfintf("*\n"); case 2+1:pfintf("**\n");}switch(a-I-{case 1:pfintf("*\n"); case c:printf("**\n");}

运行下面程序时,从键盘输入字母H,则输出结果是 main() { char ch; ch=getchar(); swimh(ch) {case'H':printf("Hello!\n"); case'G':printf("Good morning!\n"); default:printf("Bye_Bye!\n"); } }A.Hello!B.Hello! GoodMoring!C.Hello! Good moming! Bye_ye!D.Hello! Bye_ye!

若有定义:float x=1.5;int a=1,b=3,c=2;则正确的switch语句是______。A.switch (x) {case 1.0: printf("*\n"); case 2.0: printf("**\n");}B.switch ( (int)x); {case 1: printf("*\n"); case2: printf("**\n");}C.switch (a+b) {case 1:printf("*\n"); case 2+1: printf("**\n");}D.switch (a+b)) {case 1: pfintf("*\n")}; case c: printf("**\n"));}

下列程序段的输出结果是【】。int n=c; switch(n++) {default:printf(errorc;switch(n++){default:printf(error);break;case a:case A:case b:case B:printf(good);break;case c:caseC:printf(pass);case d:caseD:printf(warn);}

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

若有定义:float x=1.5;int a=1,b=3,c=2; 则正确的switch语句是( )。A.switch(x) { case 1.0: printf("*\n"); case 2.0: printf(" * * \n" );B.switch((iht)x); { case 1: printf(" * \n" ); case 2: printf(" * * \n" ); }C.switch(a +b) { case 1: printf(" * \n" ); case 2 + 1: printf(" * * \n" ); }D.switch(a + b) { case 1: pfintf(" * \n" ); case c: pfintf(" * * \n"); }

#includemain(){ char str[ ]=“The C program”,c;int i;for(i=2;(c=str[i])!=‘\0’;i++){ switch(c){ case ‘g’: ++i; break;case ‘o’: continue;default: printf(“%c”,c); continue;}printf(“*”);}printf(“\n”);}

单选题有以下程序#include main(){ int k=5,n=0; do {  switch(k)  {   case 1:case 3:n+=1;k--;break;   default:n=0;k--;   case 2:case 4:n+=2;k--;break;  }  printf(%d,n); }while(k0n5);}程序运行后的输出结果是(  )。A235B0235C02356D2356