网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

21、运行下面程序时,从键盘输入字母I,则输出结果是(). #include <stdio.h> int main() { switch(getchar()) { case 'I':printf("I love\n"); case 'C':printf("Chnia!\n"); default:printf("You are OK!\n"); } return 0; }

A.I love Chnia! You are OK!

B.I love

C.China

D.I love Chnia! You are OK!


参考答案和解析
C 本题考查switch语句。因为ch=A,所以第一个switch语句,执行case~A后面的语句,输出AAAA.没有遇到break语句,所以接着再执行case'B'和default,分别输出BBBB和CCCC。
更多 “21、运行下面程序时,从键盘输入字母I,则输出结果是(). #include <stdio.h> int main() { switch(getchar()) { case 'I':printf("I love\n"); case 'C':printf("Chnia!\n"); default:printf("You are OK!\n"); } return 0; }A.I love Chnia! You are OK!B.I loveC.ChinaD.I love Chnia! You are OK!” 相关考题
考题 以下程序的输出结果是main(){int a,i;a=0;for(i=1;i<5;i++){switch(i){case 0:case 3:a+=2;case 1:case 2:a+=3;default:a+=5;}}printf("%d\n",a);}A.31B.13C.10D.20

考题 以下程序的输出结果是main(){ int a,i;a=0;for(i=1;i5;i++){ switch(i){ case 0:case 3:a+=2;case 1:case 2:a+=3;default:a+=5; }}printf("%d\n",a);}A.31B.13C.10D.20

考题 运行下面程序时,从键盘输入字母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 i=3; switch(i) { case 1: case 2:printf("%d",i); case 3: case 4:break; default:printf("OK"); } }A.0B.3C.OKD.没有任何输出

考题 下列程序的输出结果是()。 include main() {int a=0,i; for(i=1;i 下列程序的输出结果是( )。#include<stdio.h>main(){ int a=0,i;for(i=1;i<5;i++){ switch(i){ case 0:case 3:a+=1;case 1:case2:a+=2;default:a+=3;}}printf("%d",a);}A.19B.18C.6D.8

考题 以下程序段的运行结果是( )。 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; } } }

考题 下列程序的输出结果是()。includemain(){int a=0,i; for(i=1;i 下列程序的输出结果是( )。 #include<stdio.h> main() { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=1; case 1: case 2:a+=2; default:a+=3; } printf("%d",A) ; }A.19B.18C.6D.8

考题 下列程序的输出结果是______。 main() { int i=3; switch(i) { case1: case2:printf("%d",i); case3: case4:break; default: printf ("OK"); } }A.0B.3C.OKD.没有任何输出

考题 以下程序的运行结果是( )。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");}

考题 有以下程序: include main ( ) int i;for(i =0;i 有以下程序: #include <stdio.h> main ( ) int i; for(i =0;i <3 ;i ++ ) switch (i) case 0: printf(" % d" ,i); case 2: printf(" % d" , i); default: printf( "% d" , i);程序运行后的输出结果是( )。A.22111B.21021C.122D.12

考题 有以下程序: main() { char k: int i; for(i=1:i<3;i++) { scanf("%c",k); switch(k) { case'0':printf("another\n"); case'1':printf("number\n"); } } } 程序运行时,从键盘输入:01<回车>,程序执行后的输出结果是 ______。A.another numberB.another number anotherC.another number numberD.number number

考题 有以下程序 main() { int i; for(i=0;i<3;i++) switch(i) { case 0: printf("%d",i); case 2: printf("%d",i); default: printf("%d",i); } } 程序运行后的输出结果是______。A.22111B.21021C.122D.12

考题 有以下程序 main() {int i; for(i=0;i<3;i++) switch(i) { case0:printf("%d",i); case2:printf("%d",i); default:printf("%d",i); } } 程序运行后的输出结果是A.22111B.21021C.122D.12

考题 下列程序的输出结果是()。 include main() {int a=0,i; for(i=1;i 下列程序的输出结果是( )。#include<stdio.h>main(){int a=0,i;for(i=1;i<5;i++){Switch(i){case 0:case 3:a+=1;case 1:case 2:a+=2;default:a+=3;}}printf("%d",a) :}A.19B.18C.6D.8

考题 有以下程序#include stdio.hvoid func(int n){ int i;for(i=0;i=n;i++) printf(”*”);printf(”#”).}main( ){ func(3); printf(”???? ”); func(4); printf(”\n”); }程序运行后的输出结果是A)****#????***#B)***# ????*** *#C)**#????*****#D)****#????*****#

考题 以下程序的输出结果是( )。 main { int i; for(i=0;i3;i++) switch(i){case 0:printf("%d",i); case 2:printf("%d",i); default:printf("%d",i); } }A.000102B.000020C.000122D.000111

考题 有以下程序 main( ) { char k; int l; for(i=1;i<3;i++) { scanf(“%c”,k); switch(k) { case ‘0’: printf(“another\n”); case ‘1’: printf(“number\n”); } } } 程序运行时,从键盘输入:01回车,程序执行后的输出结果是( )A.another numberB.another number anotherC.another number numberD.number number

考题 以下程序的输出结果是()。includemain(){int a,i;a=0; for(i=1;i 以下程序的输出结果是( )。 #include <stdio.h> main() { int a,i;a=0; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+=2; case 1: case 2:a+=3; default:a+=5; } } printf("%d\n",a); }A.31B.13C.10D.20

考题 运行下面程序时,从键盘输入字母H,则输出结果是includemain(){ char ch;ch=getchar();s 运行下面程序时,从键盘输入字母H,则输出结果是 #include<stdio.h> main() { 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! GoodMoring!C.Hello! Goodmorning! Bye_Bye!D.Hello! Bye_Bye!

考题 以下程序运行后的输出结果是main{ int i,m=0,n=0,k=0; for(i=9;i=11;i++) switch(i/10) { case 0: m++;n++;break;  case 1: n++;break;  default:k++;n++; } printf("%d %d %d\n",m,n,k);}

考题 运行下面程序时,从键盘输入字母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!

考题 以下程序的输出结果是( )。 main() { int a=0,i; for(i=1;i<5;i++) { switch(i) { casc 0: case 3:a+=2; case 1: case 2:a+=3; default:a+=5; } } printf("%d\n",a); }A.31B.13C.10D.20

考题 有以下程序:includemain(){char k; int i; for(i=1;i 有以下程序: #include <stdio.h> main() { char k; int i; for(i=1;i<3;i++) { scanf("%c",k); switch(k) { case '0': printf("another\n"); case '1': printf("number\n"); } { } 程序运行时,从键盘输入:01<回车>,程序执行后的输出结果是( )。A.another numberB.another number anotherC.another numberD.number number

考题 下列程序的输出结果是_______。 main() { int i=3; switch(i) { case1: case 2:printf("%d",i) case 3: case 4:break; default : printf("OK") } }A.0B.3C.OKD.没有任何输出

考题 下列程序的输出结果是______。 main() { int i=3; switch(i) { case 1: case 2:printf("%d",i); case 3: case 4:break; default:printh("OK"; } }A.0B.3C.OKD.没有任何输出

考题 以下程序的输出结果是( )。main(){ int i; for(i=0;i3;i++) switch(i) { case 0:printf(3;i++)switch(i){ case 0:printf(%d,i);case 2:printf(%d,i);default:printf(%d,i); }}A.000102B.000020C.000122D.000111

考题 #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”);}