在执行下述程序时,若从键盘输入字母H,则输出结果是()。 #include <stdio.h> int main() { char ch; ch=getchar(); switch(ch) { case 'H':printf("Hello! n"); case 'G':printf("Good morning! n"); } }

在执行下述程序时,若从键盘输入字母H,则输出结果是()。 #include <stdio.h> int main() { char ch; ch=getchar(); switch(ch) { case 'H':printf("Hello! n"); case 'G':printf("Good morning! n"); } }


参考答案和解析
B 本题中a的值为6,b的值为8,最后s的值为8,s*=s等价于s=s*s。

相关考题:

下列程序运行时,若输入labced12df回车 输出结果为【10】#include stdio.hmain( ){char a =0,ch;while((ch=getchar())!=’\n’){if(a2!=0(ch’a’ch=’z’)) ch=ch-‘a’+’A’;a++;putchar(ch);}printf(“\n”);}

要求通过 while 循环不断读入字符 , 当读入字母 N 时结束循环 。 若变量已正确定义 , 以下正确的程序段是A)while((ch=getchar())!='N') printf(" % c",ch);B)while(ch=getchar()!='N') printf(" % c",ch);C)while(ch=getchar()=='N') printf(" % c",ch);D)while((ch=getchar())=='N') printf(" % c",ch);

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

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

下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,输入字符1,则输出3,请填空。#include#include#define M 81int fun(char *ss, char c){ int i=0;for(; ( );ss++)if(*ss==c)i++;return i;}main(){ char a[M], ch;clrscr();printf("\nPlease enter a string: "); gets(a);printf("\nPlease enter a char: "); ch=getchar();printf("\nThe number of the char is: %d\n", fun(a,ch));}

请补充函数fun(),该函数的功能是:返回字符数组中指定子符的个数,指定字符从键盘输入。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80int fun (char s[],char ch){int i=0, n=0;while(【 】){if(【 】)n++;i++;}【 】;}main ( ){int n;char str[N], ch;clrscr ();printf ("\nInput a string: \n");gets (str);printf ("\nInput a charactor: \n" ;scanf ("%c", ch);n=fun (str, ch);printf("\nnumber of %c:%d", ch, n);}

在执行以下程序时,如果从键盘上输入ABCdef,则输出为______。include main(){char 在执行以下程序时,如果从键盘上输入ABCdef<回车>,则输出为______。#include <stdio.h>main (){ char ch; while ((ch=getchar())!="\n") { if (ch>='A' ch<='B')ch=ch+32; else if (ch>='a' ch<='z')ch=ch-32; printf("%c",ch); } printf("\n");}A.ABCdefB.abcDEFC.abcD.DEF

执行下面的程序时,输入abc(其中CR代表回车),输出结果是()。includeinclude 执行下面的程序时,输入abc<CR>(其中CR代表回车),输出结果是( )。 #include<stdio.h> #include <string.h> main() { char ch; while((cn=getchar())!='n') { switch(ch-'a') { case 0: putchar(ch+1); case 1:putchar(ch+1);break; case 2:putchar(ch+2); caSe 3:putchar(ch+2);break; } } }A.abcB.bbcC.abcdD.bbcee

有以下程序:includeunion pw{int i; char ch[2];}a;main(){a.ch[0]=13;a.ch[1]=0;prin 有以下程序: #include<stdio.h> union pw { int i; char ch[2]; }a; main() { a.ch[0]=13;a.ch[1]=0;printf("%d\n",a.i);} 程序的输出结果是( )。A.13B.14C.208D.209

以下程序的输出结果是()。includecharcchar(chareh){if(ch>='A,ch 以下程序的输出结果是( )。 #include <stdio.h> charcchar(char eh) { if(ch>='A,ch<='Z') ch=ch-'A'+'a'; return ch; } main() { char s[]="ABC+abc=defDEF",*p=s; while(*p) { *p=cchsr(*p); p++; } printf("%s\n",s); }A.abc+ABC=DEFdefB.abc+abc=defdefC.abcABCDEFdefD.abcabcdefdef

请编写函数fun(),它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,输入字符1,则输出3。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<coio.h>include<stdio.h>define M 81int fun(char *ss,char c){}main(){ char a[M],ch;clrscr();printf("\nPlease enter a string:");gets(a);printf("\nPlease enter a char:");ch=getchar();printf("\nThe number of the char is:%d \n",fun(a,ch));}

若程序执行时的输入数据是"2473",则下述程序的输出结果是includevoid main(){int cs;w 若程序执行时的输入数据是"2473",则下述程序的输出结果是 #include<stdio.h> void main() { int cs; while((cs=getchar())!=,'\n') {switch(cs='2') { case0 case 1:putchar(cs+4); case 2:putchar(cs+4); break; case 3:putchar(cs+3);default:putchar(cs+2);}}}A.668977B.668966C.6677877D.6688766

若执行下列程序时从键盘上输入2,则输出结果是()。 inclUde main() {int a; scanf("%d", 若执行下列程序时从键盘上输入2,则输出结果是( )。#inclUde<stdio.h>main(){int a;scanf("%d",A);if(a++<3)printf("%d\n",A);else printf("%d\n",a--);}A.1B.3C.2D.4

下列程序运行时,若输入labcedf2df输出结果为【】。 include main(){char a=0,ch; wh 下列程序运行时,若输入labcedf2df<回车>输出结果为【 】。include<stdio.h>main(){ char a=0,ch;while((ch==getchar())!='\n'){ if(a%2!=0(ch>='a'ch<='z')) ch=ch'a'+'A';a++;prtchar(ch);}printf("\n");}

有如下程序includemain(){int v1=0,v2=0; char ch; while((ch=getchar())!='') switc 有如下程序 #include<stdio.h> main() { int v1=0,v2=0; char ch; while((ch=getchar())!='#') switch(ch) { case 'a'; casff 'h'; default:v1++; case '0';v2++; } printf("%d,%d\n",v1,v2); } 如果从键盘上输入china#<回车>,则程序运行结果为 ( )A.2,0B.5,0C.5,5D.2,5

下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。includeunion pw{int 下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。#include<stdio.h>union pw{ int i;char ch[2];}a;main (){ a.ch[0]=13;a.ch[1]=0; printf("%d\n",a.i);}A.13B.14C.208D.209

以下程序运行后的输出结果是( )。 include main() {char ch[]="abcd",x[4][4];int i; f 以下程序运行后的输出结果是( )。 include<string.h> main() {char ch[]="abcd",x[4][4];int i; for(i=0;i<4;i++)strcpy(x[i],ch); for(i=0;i<4;i++)printf("%s",x[i][i]); printf("\n"); }

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

有以下程序: include main() {char ch1,ch2;int n1,n2;ch1=getchar();ch2=getehar();n1 有以下程序:include <stdio.h>main(){ char ch1,ch2;int n1,n2;ch1=getchar();ch2=getehar();n1=ch1-'0'; n2=n1*10+(ch2-'0');printf("%d\n",n2);}程序运行时输入:12<回车>,执行后的输出结果是【 】。

运行以下程序后,如果从键盘上输入china,贝愉出结果为_______。includemain(){in 运行以下程序后,如果从键盘上输入china#<回车>,贝愉出结果为_______。 #include<stdio.h> main() { int v1=0,v2=O;char ch; while((ch=getchar())!='#') switch(ch) { case'a': case'h': default:v1++; case'O':v2++; } printf("%d,%d\n",v1,v2); }A.2,0B.5,0C.5,5D.2,5

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

下面程序的输出结果是______。includemain(){char ch[7]={"12ab56"}; int i,s=0; for(i 下面程序的输出结果是______。 #include<stdio.h> main() { char ch[7]={"12ab56"}; int i,s=0; for(i=0;ch[i]>='0'ch[i]<='9';i+=2) s=10*s+ch[i]-'0'; printf("%d\n",s); }A.1B.1256C.12ab56D.1 2 5 6

下列程序段的输出结果是【】。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);}

有以下程序: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

有以下程序:includeunion pw{int i; char ch[2]; } a;main(){a.ch[0]=13; a.ch[1]=0; 有以下程序: #include <stdio.h> union pw { int i; char ch[2]; } a; main() { a.ch[0]=13; a.ch[1]=0; printf("%d\n",a.i); } 程序的输出结果是(注意:ch[0]在低字节,ch[1]在高字节)( )。A.13B.14C.208D.209

在执行以下程序时,如果从键盘上输入:ABCdef,则输出为______。 main() { char ch; while((ch 在执行以下程序时,如果从键盘上输入:ABCdef<回车>,则输出为______。 main() { char ch; while((ch=getchar())!='\n') { if(ch>='A' ch<='Z') ch=ch+32; else if(ch>='a'ch<='2')ch=ch-32; printf("%c",ch); } printf("\n"); }A.ABCdefB.abcDEFC.abcD.DEF

运行以下程序后,如果从键盘上输入china,则输了结果为______。include main (){ 运行以下程序后,如果从键盘上输入china#<回车>,则输了结果为______。 #include <stdio. h> main () { int v1=0, v2=0; char ch ; while ((ch=getchar()) !='#') switch (ch) { case 'a': case 'h': default:vi++; case '0':v2++; } printf ("%d, %d\n",v1,v2); }A.2,0B.5,0C.5,5D.2,5

有以下程序:includemain(){int c;while((c=getchar())!='\n')switch(c-'2'){case 1:pu 有以下程序: #include<stdio.h> main() { int c; while((c=getchar())!='\n') switch(c-'2') {case 1:putchar(c+4); case 2:putchar(c+4);break; case 3:putchar(c+4); case 4:putchar(c+4);break; } printf("\n"); } 输入以下数据,<CR>代表一个回车符, 2743<CR> 程序的输出结果是( )。A.877B.966C.778D.766