文档详情

C语言选择语句题库2.pdf

发布:2023-06-28约2.46千字共4页下载文档
文本预览下载声明
1、C 语言的if 语句,当条件表达式为真时执行的语句是: A 、else 后的语句 B、if 后的语句 C、不执行语句 D、if 和else 后的语句都执行 B 2、若分支结构的某个分支需要多个语句时,必须使用一个复合语句,所谓的复合语句是: A 、一个语句 B、用{}括起来的多个语句 C、两个语句 D、多个语句 B 3、判断char 型变量c1 是否为小写字母的最简单且正确的表达式是: A 、’a’=c1=’z’ B、(c1=a)(c1=z) C、(c1’a’)(c1’z’) D、(c1=’a’)(c1=’z’) D 4 、判断char 型变量c1 是否为数字0-9 字符最简单且正确的表达式是: A 、’0’=c1=’9’ B、(c1=0)(c1=9) C、(c1’0’)(c1’9’) D、(c1=’0’)(c1=’9’) 5、以下不正确的If 语句是: A 、if(xy); B、if(x!=y) scanf (“%d”,x) else scanf (“%d”,y); C、if(x==y) x+=y; D、if(xy){x++;y++;} B 6、以下关于switch 语句和break 语句的描述中,正确的是: A 、在switch 语句中必须使用break 语句 B、break 语句只能用于switch 语句中 C、在switch 语句中,可以根据需要使用或不使用break 语句 D、break 语句是switch 语句的一部分 C 7、以下关于if 语句的描述错误的是: A 、条件表达式可以是任意的表达式 B、条件表达式只能是关系或逻辑表达式 C、条件表达式的括号不可以省略 D、与else 配对的if 语句是其之前最近的未配对的if 语句 B 8、程序设计的三种基本结构是 A 、顺序结构、选择结构、分支结构 B、递归结构、选择结构、循环结构 C、顺序结构、逻辑结构、循环结构 D、顺序结构、选择结构、循环结构 D 填空题 1、下列程序的运行结果是___________________ #include stdio.h main() {int x=1,a=0,b=0; switch(x) {case 0: b++; case 1:a++; case 2:a++;b++; } Printf(“a=%d,b=%d\n”,a,b); } a=2,b=1 2、下列程序的运行结果是___________________ #include stdio.h main() { int a=1,b=3,c=5; If(c=a+b) printf(“yes\n”); else printf(“no\n”); } yes 3、若输入为:-1 -2,下列程序的运行结果是___________________ #include stdio.h main() { int a,b,m,n; scanf(“%d%d”,a,b); m=1;n=1; if(a0) m=m+n; if(ab) n=2*m; else if(a==b) n=5; else m=m+n; printf(“m=%d n=%d\n”,m,n);} m=2 n=1 4 、下列程序的运行结果是___________________ #include stdio.h main() { int a=100; If(a0) printf(“%d\n”,a100); else printf(“%d\n”,a=100); } 0 5、下列程序的运行结果是___________________ #include stdio.h main() { int n=0,m=1,x=2; if(!n) x-=1; if(m) x-=2; if(x) x-=3; printf(“%d\n”,x); } -4 6、下列程序的运行结果是___________________ #include stdio.h main() { int m=5; if(m++5) printf(“%d\n”,m); else printf(“%d\n”,m--); } 6 编程题 1、判断整数N 能否同时被3 和7 整除,如果能则打印“YES
显示全部
相似文档