版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
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 (優(yōu)先級) 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(函數(shù)首部) 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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國冷熱水管道溫度計數(shù)據(jù)監(jiān)測研究報告
- 二零二五年度臨時安全警示設(shè)施搭建服務(wù)合同4篇
- 2025至2030年中國中藥冷藏貯罐數(shù)據(jù)監(jiān)測研究報告
- 2025年中國2-氯-4-氟苯酚市場調(diào)查研究報告
- 二零二四年度小微企業(yè)小額短期借款合同3篇
- 2025年中國電話機天線市場調(diào)查研究報告
- 2025年中國射頻機房收費系統(tǒng)市場調(diào)查研究報告
- 6G切片安全認證與授權(quán)機制-深度研究
- 植物油加工碳排放控制-深度研究
- 內(nèi)部控制與合規(guī)性研究-深度研究
- JB-T 8532-2023 脈沖噴吹類袋式除塵器
- 深圳小學(xué)英語單詞表(中英文)
- 護理質(zhì)量反饋內(nèi)容
- 山東省濟寧市2023年中考數(shù)學(xué)試題(附真題答案)
- 抖音搜索用戶分析報告
- 板帶生產(chǎn)工藝熱連軋帶鋼生產(chǎn)
- 鉆孔灌注樁技術(shù)規(guī)范
- 2023-2024學(xué)年北師大版必修二unit 5 humans and nature lesson 3 Race to the pole 教學(xué)設(shè)計
- 供貨進度計劃
- 國際尿失禁咨詢委員會尿失禁問卷表
- 彌漫大B細胞淋巴瘤護理查房
評論
0/150
提交評論