#include
void YesNO(char ch)
{
switch(ch)
{
case 'Y':
case 'y':printf("
This is YES.
"); ;
case 'N':
case 'n': printf("
This is NO.
");
}
}
main()
{
char ch;
printf("
Enter a char 'Y', 'y' or 'n', 'N': ");
ch= ;
printf("ch:%c",ch);
YesNo(ch);
}
break --- getchar()
举一反三
- 以下程序的功能是根据输入的“y”(“Y”)与“n”(“N”),在屏幕上分别显示出“This is YES.”与“This is NO.”。请填空。 void YesNo(char ch) { switch(ch) { case ‘y’: case ‘Y’: printf(“\nThis is YES.\n”); _________; case ‘n’: case ‘N’: printf(“\nThis is No.\n”); } } int main() { char ch; printf(“Enter a char ‘y’,‘Y’or‘n’,‘N’:”); ch=____________; printf(“ch:%c”,ch); YesNo(ch); }
- 若有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”); }
- 下列程序运行时,若输入1abcedf2df<回车>,则程序的输出结果为______。 #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++;putchar(ch); printf("\n");
- 执行下列程序段,若从键盘输入字符y,则结果是【 】int x=10, y=20, z;char ch;scanf("%c", &ch);switch(ch){ case 'x':z=x+y;break; case 'y':z=x-y; default:z=0;}printf("%d",z); A: 0 B: -10 C: 30 D: 以上答案都不对
- 中国大学MOOC: 有如下程序#include <stdio.h>main() { char ch = A; while (ch < D) { printf("%d", ch - A); ch++; } printf("\n");}程序运行后的输出结果是( )
内容
- 0
有以下程序 #include main( ) { char ch[] = "abc"; ch[0] ^= ch[0]; ch[1] |= ch[1]; ch[2] &= ch[2]; printf("%d%c%c\n",ch[0],ch[1],ch[2]); } 程序运行后的输出结果是
- 1
有以下程序: #include<stdio.h> . main() {int al=0,a2=0,a3=0; char ch; while((ch=getchar())!='n') switch(ch) {case 'A':a1++; case 'B':a2++; default:a3++; } printf("%d,%d,%d",a1,a2,a3);} 现从键盘上输入AAAAABBBC<回车>,则程序执行后的输出结果是( )
- 2
有以下程序#include main(){ char ch = 'A'; while (ch < 'D') { printf("%d", ch - 'A'); ch++;}printf("\n");}程序运行后的输出结果是( )。 A: 123 B: ABC C: abc D: 012
- 3
#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”); } } 运行结果为( )
- 4
苹果好吃吗?我可以__吗?Pínɡɡuǒ hǎochī mɑ? Wǒ kěyǐ__mɑ?? 尝尝了chánɡchɑnɡ le;|一下儿尝yíxiàr chánɡ|了尝尝le;chánɡchɑnɡ;|尝尝chánɡchɑnɡ