版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、The C Programming Language EXAMINATION PAPER and AnswerSection 1: Fill in the blanks(2 mark for each item, total 20 marks) 1.1 The value of expression 1<10<5 is _1_.1.2 The valu
2、e of expression 1+4/5+15<7+4%5+(8,10) is _1_. 1.3 What value is stored into the int variable b in each of the following? Assume that b is int variables with b containing 12. b*=2+3 b=_60_.1.4 The statement for (i=1; i<=9; i+) pr
3、intf(“%3d”, _3*i+2_);prints out the following numbers: 1 4 7 10 13 16 19 22 25. 1.5 According to the declaration: int a35,the number of elements of array a is 15 .1.6 The
4、 following code fragment will output _2WE_.char s="WEIHAI"sstrlen(s)/2-1=0;printf("%d%sn",strlen(s),s);1.7 The output of the following statements is _k=10,s=25_.int k, s;for(k=1, s=0; k<10; k+) if
5、0;(k%2=0) continue; s += k; printf("k=%d s=%d", k, s); 1.8 The running result of following program is: _ 2,6,42, vo
6、id fun() static int a=1; a*=a+1; printf(“%d,”,a); main() int cc; for(cc=1;cc<4;cc+) fu
7、n(); 1.9 The output of the following program is _5_.f (int x) if(x<=1) return 1; else return f(x-1)+f(x-2); void main( ) printf("%d", f(4);&
8、#160; 1.10 The output of the following statements is _-1_.printf("%d", 'M' - 'N')Section 2: Single Choice(2 mark for each item, total 40 marks) 122.1 Every C progra
9、m consists of at least how many functions? AA1 B2 C3 D42.2 The precedence (优先级) of operator _ is the lowest one. AA, B!= C&& D= 2.3 Which of following is an illegal user-define symbol?&
10、#160; CAn BPAY_DAY C6Set Dnum52.4 Which operator can only be applied to integers? AA%= B/ C= D<= 2.5 According to the C syntax, _is the legal character constant in the followings. BA
11、n B18 C Dxab2.6 The expression _can NOT express the statement ”both x and y are zero”. CAx=0 && y=0 B!x && !y Cx=0 | y=0D!(x | y)2.7 The statement _ is correct if a is an integer variable and b is a double precision float variable . CAscanf(“%d,%f”, &a, &b); Bscanf(“a=%d b=%*
12、f”, &a, &b); Cscanf(“%d%*lf”, &a, &b); Dscanf(“%d%*lf”, &a );2.8 Assuming x is 10, what is the output: printf(“%d”,+x); DA8
13、60; B9 C10 D112.9 Determine the output of&
14、#160;the following program. Bmain() int n = 8; while (n > 5) n-; printf(“%d”, n); A876 B765 C8765 D7654 2
15、.10 The running result of following program is . A#include<stdio.h>main()int a=1;switch(a) case 0: printf("() ");case 1: printf("(*>_<*)");case 2: printf(" (_) ");break; default: printf("(*_*) ");printf("%d",a);A(*>_<*)(_)1B()
16、(*>_<*)1C(*>_<*) (_) (*_*)1D (_) (*>_<*)12.11 What would the heading(函数首部) for a value-returning function named Mul look like if it had two int parameters,num1 and num2, and returned a int result? AAint Mul(int num1,int num2)Bint Mul(num1,num2);Cvoid Mul(int num1,int num2)Dint Mul(
17、int,int); 2.12 The following code fragment prints out _. B#define MA(x, y) (x)*(y) int i = 2; i = 3/MA(i, i+2)+5; printf(“%dn”, i); A11 B9 C8 D52.13 If strcopy is used in th
18、e program,what kind of file shall be included? DAstdio.h Bstring,h Cmath.h Dstring.h2.14 The program segment (程序段) below reverses(逆序) the string s in the place, which one is written correctly? BAfor (i = 0, j = strlen(s
19、); i < j; i+, j-) c = si, si = sj, sj = c; Bfor (i = 0, j = strlen(s)-1; i < j; i+, j-) c = si, si = sj, sj = c;
20、C for (i = 0, j = strlen(s)-1; i < j; i+, j-) c = si; si = sj; sj = c; Dfor (i = 0, j = strlen(s); i < j; i+, j-)
21、60; c = si; si = sj; sj = c; 2.15 In the statement while(x), choose the equivalent expression for the x. DAx=0 Bx=1 Cx!=1 Dx!=02.16 _ is wrong. CAchar *p="string"Bchar str ="string"
22、;Cchar str10; str="string" Dchar *p; p="string" 2.17 which one statement is correct ? AAchar s23=“xy”; Bchar s14=“abcd”;Cchar s33=a,x,y;Dchar s423=“xyz”,“abc”;2.18 Determine the output of the value of b. CInt a42 = 1,2,3,4,5,6,7,8;b = *(*(a + 2
23、) + 1);A4B5C6 D72.19 The running result of following program is . Cinclude “stdio.h”main() struct person char name30; char gender; int age; student;A30 B32 C33 D342.20 What is the functionality of function “rewind”? CAopen the file again;Breturn the
24、 length of the file Cpush the pointer to the beginning of the file Dpush the pointer to the end of the fileSection 3: Read each of the following programs and answer questions (3 marks for item, total marks: 6) 33.1 When&
25、#160;input: how are you? <ENTER>, the output is _ How Are You _.#include <stdio.h> void main( ) int word; char ch; word=0; whi
26、le(ch=getchar()!='?') if (ch=' ') word=0; else if(word=0) word=1; if(ch<='z'&&ch>='a') ch=ch-'a'+'A' &
27、#160; putchar(ch); 3.2 The following program will output i=6, k=4.#include <stdio.h> void main() int i,j,k=19; while (i=k-1) k-=3; if(k%5=0) i+; continue; els
28、e if(k<5) break; i+; printf(“i=%d,k=%dn”,i,k); Section 4: According to the specification, complete each program (2 mark for each blank, total: 20 marks) 2344.1 calculate the value of k=1+3+5+ +99. #in
29、clude <stdio.h> main( ) int i , k=0; for (i=1;i<=100; _ (1) i+=2/i+,i+/i=i+2_ ) k = _(2)_i+k_ printf(“k = %dn”,k); 4.2 The function RemoveZeroElements(array,n)goes through an array of integers and eliminates any elements
30、whose value is 0.For example,suppose that scores contains an array of score on an optional exam as shown: scores 650950079820849486900At this point,the function should remove the 0 scores,compressing the array into the following configuration: 65 95798284948690? Filling the blank to complete the
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 肛瘘手术患者营养支持
- 腰椎间盘突出预防策略
- 智研咨询发布-2026年中国真空镀铝纸行业市场竞争格局、行业政策及需求规模预测报告
- 卫生院干部教育培训制度
- 国企审计风控工作制度
- 三重一大选人用人制度
- 内部审计激励制度
- 全年教育培训制度
- 培训中心绩效考核制度
- 医药公司财务审计制度
- 2024年电脑动画13464自考复习题库(含答案)
- 2024年中国铁路上海局集团有限公司招聘笔试参考题库含答案解析
- 大学有机化学实验必做试题
- 幼儿园小班绘本故事《大熊山》
- S型单级双吸离心泵安装说明中英文
- 建设施工分包安全管理培训讲义图文并茂
- (完整版)英语仁爱版九年级英语下册全册教案
- JJG 602-2014低频信号发生器
- GA 1800.6-2021电力系统治安反恐防范要求第6部分:核能发电企业
- 教学课件-氢氧化钠溶液的配制与标定
- 人教版政治七年级下册全套课件
评论
0/150
提交评论