二级C语言考试必备(真题)考点18 switch-case 语句.doc_第1页
二级C语言考试必备(真题)考点18 switch-case 语句.doc_第2页
二级C语言考试必备(真题)考点18 switch-case 语句.doc_第3页
二级C语言考试必备(真题)考点18 switch-case 语句.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【2000年4月】(37) 若有定义: float w; int a, b; 则合法的switch语句是 A) switch(w) B) switch(a); case 1.0: printf(*n); case 1 printf(*n); case 2.0: printf(*n); case 2 printf(*n); C) switch(b) D) switch(a+b); case 1: printf(*n); case 1: printf(*n); default: printf(n); case 2: printf(*n); case 1+2: printf(*n); default: printf(n); 【答案】C【2000年9月】(23) 有如下程序 main() int x=1,a=0,b=0; switch(x) case 0: b+; case 1: a+; case 2: a+;b+; printf(“a=%d,b=%dn”,a,b); 该程序的输出结果是 A) a=2,b=1 B) a=1,b=1 C) a=1,b=0 D) a=2,b=2 【答案】A【2001年4月】(24) 若a、 b、c1、c2、x、y、均是整型变量,正确的switch语句是 A) swich(a+b); B) switch(a*a+b*b) case 1:y=a+b; break; case 3: case 0:y=a-b; break; case 1:y=a+b;break; case 3:y=b-a,break; C) switch a D) switch(a-b) case c1 :y=a-b; break default:y=a*b;break; case c2: x=a*d; break case 3:case 4:x=a+b;break; default:x=a+b; case 10:case 11:y=a-b;break; 【答案】D【2001年4月】(10) 下列程序段的输出结果是 【 】 。 int n=c; switch(n+) default: printf(“error”);break; case a:case A:case b:case B:printf(“good”);break; case c:case C:printf(“pass”); case d:case D:printf(“warn”); 【答案】passwarn【2001年9月】(26) 以下程序的输出结果是 main() int a=0,i; for(i=1;i5;i+) switch(i) case 0: case 3:a+=2; case 1: case 2:a+=3; default:a+=5; printf(%dn,a); A) 31 B) 13 C) 10 D) 20 【答案】A【2002年4月】(26)有以下程序 main() int a=15,b=21,m=0; switch(a%3) case 0:m+;break; case 1:m+; switch(b%2) default:m+; case 0:m+;break; printf(%dn,m); 程序运行后的输出结果是_。 A) 1 B) 2 C) 3 D) 4 【答案】A【2003年4月】(20) 有以下程序 main() int i; for(i=0;i3;i+) switch(i) case 1: printf(%d,i); case 2: printf(%d,i); default: printf(%d,i); 执行后输出的结果是 A) 011122 B) 012 C) 012020 D) 120 【答案】A【2003年9月】(9)以下程序运行后的输出结果是 【 】 。main() int i,m=0,n=0,k=0;for(i=9; i=11;i+)switch(i/10) case 0: m+;n+;break;case 10: n+; break;default: k+;n+;printf(%d %d %dn,m,n,k);【答案】1 3 2【2004年4月】22、有以下程序main( ) char k; int i; for(i=1;i3;i+) scanf(%c,&k); switch(k) case 0: printf(anothern); case 1: printf(numbern); 程序运行时,从键盘输入:01,程序执行后的输出结果是()A) another B)another C)another D)number number number number number another number 【答案】C【2004年9月】20.有以下程序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)022111 B)021021 C)000122 D)012【答案】C【2004年9月】9.以下程序运行后的输出结果是【 】。main() int x=

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论