【计算机类职业资格】二级C语言-267及答案解析.doc
《【计算机类职业资格】二级C语言-267及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】二级C语言-267及答案解析.doc(23页珍藏版)》请在麦多课文档分享上搜索。
1、二级 C 语言-267 及答案解析(总分:100.00,做题时间:90 分钟)一、选择题(总题数:50,分数:100.00)1.有以下程序 #includestdio.h main() int i, sum; for(i=1; i6; i+)sum+=i; printf(“%d/n“, sum); 程序运行后的输出结果是_。(分数:2.00)A.0B.随机值C.15D.162.以下叙述中正确的是_。(分数:2.00)A.如果根据算法需要使用无限循环(即通常所称的“死循环”),则只能使用 while 语句B.对于“for(表达式 1;表达式 2;表达式 3)循环体”首先要计算表达式 2 的值,以
2、便决定是否开始循环C.对于“for(表达式 1;表达式 2;表达式 3)循环体”,只在个别情况下才能转换成 while 语句D.只要适当地修改代码,就可以将 do-while 与 while 相互转换3.若变量已正确定义 for(x=0, y=0; (y!=99 x+) 则以上 for 循环_。(分数:2.00)A.执行无限次B.执行 3 次C.执行 4 次D.执行次数不定4.若有以下程序 #includestdio.h main() int a=6, b=0, c=0; for(;a;) b+=a; a-=+c; printf(“%d, %d, %d/n“, a, b, c); 则程序的输出
3、结果是_。(分数:2.00)A.0, 18, 3B.1, 14, 3C.0, 14, 3D.0, 14, 65.有以下程序 #includestdio.h main() int i=5; do if(i%3=1) if(i%5=2) printf(“*%d“, i); break; i+; while(i!=0); printf(“/n“); 程序的运行结果是_。(分数:2.00)A.*7B.*3*5C.*5D.*2*66.若变量已正确定义,有以下程序段 i=0; do printf(“%d,“ ,i); while(i+); printf(“%d/n“, i); 其输出结果是_。(分数:2.
4、00)A.0, 1B.0, 0C.1, 1D.程序进入无限循环7.若有以下程序 #includestdio.h main() int a=-2, b=0; do+b; while(a+); printf(“%d, %d/n“, a, b); 则程序的输出结果是_。(分数:2.00)A.2, 3B.0, 2C.1, 2D.1, 38.以下程序段中的变量已正确定义 for(i=0; i4; i+, i+) for(k=1; k3; k+); printf(“*“); 该程序段的输出结果是_。(分数:2.00)A.*B.*C.*D.*9.有以下程序 #includestdio.h main() in
5、t i, j; for(i=3; i=1; i-) for(j=1; j=2; j+)printf(“%d“, i+j); printf(“/n“); 程序的运行结果是_。(分数:2.00)A.2 33 44 5B.4 32 54 3C.4 53 42 3D.2 33 42 310.有以下程序 #includestdio.h main() int i, j, m=55; for(i=1; i=3; i+) for(j=3; j=i; j+)m=m%j; printf(“%d/n“, m); 程序的运行结果是_。(分数:2.00)A.1B.0C.2D.311.以下叙述中正确的是_。(分数:2.0
6、0)A.break 语句只能用于 switch 语句体中B.continue 语句的作用是:使程序的执行流程跳出包含它的所有循环C.在循环体内使用 break 语句和 continue 语句的作用相同D.break 语句只能用在循环体内和 switch 语句体内12.以下叙述中正确的是_。(分数:2.00)A.break 语句不能用于提前结束 for 语句的本层循环B.使用 break 语句可以使流程跳出 switch 语句体C.continue 语句使得整个循环终止D.在 for 语句中,continue 与 break 的效果是一样的,可以互换13.有以下程序 #includestdio.
7、h main() int i, j, x=0; for(i=0; i2; i+1 x+; for(j=0; j=3; j+) if(j%2) continue; x+; x+; printf(“x=%d/n“, x); 程序执行后的输出结果是_。(分数:2.00)A.x=8B.x=4C.x=6D.x=1214.有以下程序 #includestdio.h main() int x=8; for(; x0; x-) if(x%3) printf(“%d,“, x-); continue; printf(“%d,“, -x); 程序的运行结果是_。(分数:2.00)A.8, 5, 4, 2,B.8,
8、 7, 5, 2,C.9, 7, 6, 4,D.7, 4, 2,15.下列定义数组的语句中,正确的是_。(分数:2.00)A.int x;B.int N=10;int xN;C.int x010;D.#define N 10int xN;16.下列选项中,能正确定义数组的语句是_。(分数:2.00)A.int N=2008;int numN;B.int num;int numN;C.#define N 2008int numN;D.int num02008;17.以下叙述中正确的是_。(分数:2.00)A.数组说明符的一对方括号中只能使用整型常量,而不能使用表达式B.一条语句只能定义一个数组C
9、.每个数组包含一组具有同一类型的变量,这些变量在内存中占有连续的存储单元D.在引用数组元素时,下标表达式可以使用浮点数18.以下叙述中正确的是_。(分数:2.00)A.语句 int a8=0;是合法的B.语句 int a=0;是不合法的,遗漏了数组的大小C.语句 char a2=“A“, “B“;是合法的,定义了一个包含两个字符的数组D.语句 char a3; a=“AB“;是合法的,因为数组有三个字符空间的容量,可以保存两个字符19.有以下程序 #includestdio.h main() int x32=0, i; for(i=0; i3; i+)scanf(“%d“, xi); prin
10、tf(“%3d%3d%3d/n“, x00, x01, x10); 若运行时输入:2 4 6回车,则输出结果为_。(分数:2.00)A.2 0 4B.2 0 0C.2 4 0D.2 4 620.以下数组定义中错误的是_。(分数:2.00)A.int x23=1, 2, 3, 4, 5, 6);B.int x3=0;C.int x3=1, 2, 3, 4, 5, 6;D.int x23=1, 2, 3, 4, 5, 6;21.以下定义数组的语句中错误的是_。(分数:2.00)A.int num=1, 2, 3, 4, 5, 6;B.int num3=1, 2, 3, 4, 5, 6;C.int
11、num24=1, 2, 3, 4, 5, 6;D.int num4=1, 2, 3, 4, 5, 6;22.以下错误的定义语句是_。(分数:2.00)A.int x3=1, 2, 3, 4;B.int x43=1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3;C.int x3=0, 1, 1, 2, 3;D.int x4=1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3;23.有以下程序 #includestdio.h main() int b33=0, 1, 2, 0, 1, 2, 0, 1, 2, i, j, t=1; for(i=0; i; i+)
12、 for(j=i; j=i; j=+)t+=bibji; printf(“%d/n“, t); 程序运行后的输出结果是_。(分数:2.00)A.4B.3C.1D.924.有以下程序 #includestdio.h main() int a44=1, 4, 3, 2, 8, 6, 5, 7, 3, 7, 2, 5, 4, 8, 6, 1; int i, j, k, t; for(i=0; i4; i+) for(j=0; j3; j+) for(k=j+1; k4; k+) if(ajiaki t=aji; aji=aki; aki=t; /*按列排序*/ for(i=0; i4; i+) pr
13、intf(“%d,“, aii); 程序运行后的输出结果是_。(分数:2.00)A.8, 7, 3, 1,B.1, 6, 5, 7,C.4, 7, 5, 2,D.1, 6, 2, 1,25.有以下程序 #includestdio.h main() int i, t3=9, 8, 7, 6, 5, 4, 3, 2, 1; for(i=0; i3; i+) printf(“%d“, t2-ii); 程序执行后的输出结果是_。(分数:2.00)A.3 5 7B.7 5 3C.3 6 9D.7 5 126.下列叙述中正确的是_。(分数:2.00)A.两个连续的双引号(“)是合法的字符串常量B.两个连续
14、的单引号(“)是合法的字符常量C.可以对字符串进行关系运算D.空字符串不占用内存,其内存空间大小是 027.以下叙述中正确的是_。(分数:2.00)A.语句 char str10=“string!“;和 char str10=“string!“;并不等价B.对于字符串常量“string!“,系统已自动在最后加入了“/0“字符,表示串结尾C.对于一维字符数组,不能使用字符串常量来赋初值D.在语句 char str=“string!“;中,数组 str 的大小等于字符串的长度28.设有定义: char s81; int i=0; 以下不能将一行(不超过 80 个字符)带有空格的字符串正确读入的语句
15、或语句组是_。(分数:2.00)A.gets(s);B.while(si+=getehar()!=“/n“); si=“/0“;C.scanf(“%s“, s);D.do(scanf(“%c“, while(si+!=“/n“); si=“/0“;29.有以下程序 #includestdio.h main() char s=“012xy/08s34f4w2“; int i, n=0; for(i=0; si!=0; i+) if(si=“0“ printf(“%d/n“, n); 程序运行后的输出结果是_。(分数:2.00)A.8B.0C.7D.330.下列语句组中,正确的是_。(分数:2.0
16、0)A.char*s; s=“Olympic“;B.char s7; s=“Olympic“;C.char*s; s=“Olympic“;D.char s7; s=“Olympic“;31.以下选项中正确的语句组是_。(分数:2.00)A.char*s; s=“BOOK!“;B.char*s; s=“BOOK!“;C.char s10; s=“BOOK!“;D.char s; s=“BOOK!“;32.有以下程序 #includestdio.h main() char c25=“6938“, “8254“, *p2; int i, j, s=0; for(i=0; i2; i+) pi=ci;
17、 for(i=0; i2; i+) for(j=0; pij0; j+=2) s=10*s+pij-“0“; printf(“%d/n“, s); 程序运行后的输出结果是_。(分数:2.00)A.9284B.9824C.6982D.638533.下面选项中的程序段,没有编译错误的是_。(分数:2.00)A.char*sp, s10; sp=“Hello“;B.char*sp, s10; s=“Hello“;C.char str110=“computer“, str210; str2=str1;D.char mark; mark=“PROGRAM“;34.以下叙述中正确的是_。(分数:2.00)
18、A.不能用字符串常量对字符数组名进行整体赋值操作B.字符串常量“Hello“会被隐含处理成一个无名字符型数组,它有 5 个元素C.char str7=“string!“;在语法上是合法的,运行也是安全的D.char*str; str=“Hello“;与 char str; str=“Hello“;效果是一样的35.若要求从键盘读入含有空格字符的字符串,应使用函数_。(分数:2.00)A.gets()B.getc()C.getchar()D.scanf()36.有以下程序 #includestdio.h char fun(char *c) if (*c=“Z“ return *c; main()
19、 char s81, *p=s; gets(s); while(*p) *p=fun(p); putchar(*p); p+; printf(“/n“); 若运行时从键盘上输入 OPEN THE DOOR回车,程序的输出结果是_。(分数:2.00)A.OPEN THE DOORB.oPEN tHE dOORC.open the doorD.Open The Door37.有以下程序 #includestdio.h #includestring.h main() char str20=“One*World“, “One*Dream!“), *p=str1; printf(“%d,“, strle
20、n(p); printf(“%s/n“, p); 程序运行后的输出结果是_。(分数:2.00)A.10, One*Dream!B.9, One*Dream!C.9, One*WorldD.10, One*World38.若有定义语句: char s10=“1234567/0/0“; 则 strlen(s)的值是_。(分数:2.00)A.7B.8C.9D.1039.若有定义语句: char *s1=“OK“, s2=“ok“; 以下选项中,能够输出“OK“的语句是_。(分数:2.00)A.if(strcmp(s1, s2)!=0)puts(s2);B.if(strcmp(s1, s2)!=0)p
21、uts(s1);C.if(strcmp(s1, s2)=1)puts(s1);D.if(strcmp(s1, s2)=0)puts(s1);40.若有以下定义和语句 #includestdio.h char s110=“abcd!“, *s2=“/n123/“; printf(“%d%d/n“, strlen(s1), strlen(s2); 则输出结果是_。(分数:2.00)A.5 8B.10 5C.10 7D.5 541.若有代数式 (分数:2.00)A.sqrt(fabs(pow(n, x)+exp(x)B.sqrt(fabs(pow(n, x)+pow(x, e)C.sqrt(abs(
22、nx+ex)D.sqrt(fabs(pow(x, n)+exp(x)42.C 语言主要是借助以下哪种手段来实现程序模块化?_(分数:2.00)A.定义函数B.定义常量和外部变量C.使用丰富的数据类型D.使用三种基本结构语句43.若有以下函数首部 int fun(double x10, int*n) 则下面针对此函数的函数声明语句中正确的是_。(分数:2.00)A.int fun(double *, int*);B.int fun(double, int);C.int fun(double *x, int n);D.int fun(double x, int*n);44.若函数调用时的实参为变量
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 二级 语言 267 答案 解析 DOC
