版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、I. True/False1. ( F)Identifiers consist of letters and digits in any order, but must be in lowercase.2. (T)We create modular programs because they are easier to develop, correct and modify.3. (F)All computers use twice the amount of storage for double precision than floating point data type4. (F)Sta
2、tic variable is not created and destroyed each time the function is called, it is the default storage class used by C. 5. (T)A compound statement may be used anywhere in C program in place of a single statement.6. (F)In C language, all operators are binary operator which connecting tow operands side
3、-by-side.7. (T)The Escape Sequence is a combinations of a backslash () and a character that tells the compiles to escape from the ways these character would be normally interpreted8. (T)Extern storage class is to extend the scope of a global variable beyond its normal boundary-file. it does not caus
4、e the creation of a new variable.9. (F)After defined, the symbolic names can be used in any statement and the program can change the value of the symbolic names.10. (T)The mistake of using the assignment operator”=” in place of the relational operator”= =” results in a invalid C expressionII. Choice
5、 11. (C)For the algebraic expression 3ae/bc, which of the following C expression is invalidA) a/b/c*e*3B) 3*a*e/b/cC) 3*a*e/b*cD) a*e/c/b*312. (D)For the declarations: char w; int x; float y; double z; the data type of the value of w*x+z-y isA) floatB) charC) intD) double13. (B)For following declara
6、tion, which expression will not result in 3 ?int x10 = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *p1 ;A) x3B) p1 = x +3, *p1+C) p1 = x +2, *( p1+ )D) p1 = x +2, *+p114. (A)Which one is not endless loop?A) for (y = 0, x = 1 ; x +y ; x = i+ ) i = x ;B) for ( ; ; x + = i ) ;C) while (1) x +;D) for ( i =10 ; ; i-)
7、sum += i ;15. (B)The result of the following program ismain() int a = -2, b do b = +a; if (!b) printf(“#”); else printf(“*”); while(a5D) 35III. Fill in the blanks in each program to implement the purpose according to the description Description#1:The following program can accept elements of an array
8、 from the keyboard, and find the maximum element and corresponding index in the array. main() int x10, *p1, *p2, k; for(k = 0; k 10; k+) scanf(%d, x+k); for(p1 = x, p2 = x; p1-x * p2) p2 = 【21】 ; printf(MAX = %d, INDEX = %dn, *p2,【22】);21. A) p1B) p2p1C) xp2D) x p122. A) p1 xB) p1C) p2 x D) x p2Desc
9、ription#2: For each x, the program will calculate a corresponding y according to the relationship of x and y illustrated in the following table.xy2 x = 10x(x+2)-1 x = 22xx = -1x - 1main() int x, y; scanf(“%d”, &x); if(【23】 ) y = x * (x + 2); else if(【24】 ) y = 2 * x; else if(x 2 | | x 2 & x = 10C) x
10、 2 & x = 10D) x = 1024. A) x = 2B) x -1 | | x -1 & x -1 x = 225. A) y = -1B) y = 0C) x = 0D) x = -1IV. (1)What is the purpose of the following program? #include#define N 10 main()int t, i, j, aN+1 ;printf(“please input 10 integers:”);for (i=1; i=N; i+)scanf(“%d”, &ai);printf(“n”);for (i=1; i=N-1; i+
11、) for (j=1; j=N-i; j+)if (ajaj+1)t=aj+1; aj+1=aj; aj=t;for (i=1; i=N; i+) printf(“%d”, ai);printf(“”n);從大到小排列數(shù)字。 (2)Read the grogram and guess the result of the program#include int k = 1;char a = “IBM computer”, b = “C program”;int fuc();main()int p = 3;while (putchar(ak) k+; /*k=12*/putchar(n);prin
12、tf(“k=%d, ”, k);k=fuc(p);printf(“%d, %dn”, p,k);printf(“%c%sn”, a0, &bp);puts(&a3);int fuc(int m)int k = 0;while (putchar(bk) k+; printf(k=%dn, k);k +=m; m *=k;printf(%d, %dn, m, k);return (m+k);OUTPUT:BM computerk=12,C program k=9 36, 12 3, 48 Irogram computerV. Check Error in the program according
13、 to the following description and correct them, write the whole corrected program on the answer sheetA programmer wants to write a program to simulate a roll of the dice. The programmer decides to have the program choose two pseudo-random numbers from 1 to 6 and output the two numbers. If two values
14、 are the same, the program should also output the string Thats a pair! after printing the two values.The programmer writes the following code:#include #include #include int main(void)int dice2;srand(time(NULL);for (x = 0; x = 2; x+);dicex = rand() % 6;printf (You rolled a %d and a %d.n, dice0, dice1
15、);if (dice0 = dice1)printf(Thats a pair!n);return 0;The above code has 5 errors in it! What are they?沒有定義xfor (x = 0; x = 2; x+);應改為for (x = 0; x = 2; x+)dicex = rand() % 6;應改為(dicex = rand() % 7)+1 /*超綱*/for (x = 0; x = 2; x+);應改為x 2if (dice0 = dice1)應改為=VI. Writing a program Write a complete progr
16、am that allows the user to enter a string (assumed to be less than 25 characters long). If N is the length of the string, the program should output N rows to standard output. The first row should be the string entered by the user. The second row should be the string without its last character. The t
17、hird row should be the string without its last two characters. Etc. The Nth and final row should be only the first letter of the string.Here is a sample run, assuming the user types “Hello World!” when prompted:Enter a string: Hello World!Hello World!Hello WorldHello WorlHello WorHello WoHello WHello HelloHellHelHeHPretest and posttest loop; modular programs; binary operator; file; the amount of storage; continue break statement; Automatic variable;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 智能制造信息系統(tǒng)監(jiān)理方案
- 商用建筑水處理設備安裝方案
- 2024年司機配駕汽車租賃合同標準范本
- 2024裝修公司工裝合同范本
- 2024年產(chǎn)品定制培訓合同
- 2024英文贊助合同范本
- 路面工程預算課程設計
- 采礦學課程設計報告
- 水庫水能計算課程設計
- 2024年光纖到戶項目線路安裝合同
- 智能交通-道路交通控制基本理論和方法課件
- 無線電測向運動介紹、原理和技術課件
- 《羅密歐與朱麗葉》劇本
- 新生兒細菌及真菌感染的護理
- 六年級上冊英語課件-Unit5 Signs 第1課時 |譯林版(三起) (共23張PPT)
- 輔助生殖技術課件
- 中考生物復習課件考點必背必記部分 八年級上冊
- 三年級上冊心理健康課件-綽號大家談 全國通用(共13張PPT)
- 國有企業(yè)職務犯罪懲治與預防
- 初中信息技術川教八年級上冊 我的視頻類數(shù)字故事制作視頻類數(shù)字故事教案李彥欣
- 《“探界者”鐘揚 》電子課件
評論
0/150
提交評論