![Chapter3_6e.doc_第1頁](http://file.renrendoc.com/FileRoot1/2020-1/9/05f55ebb-7310-42c2-a638-cceb8fcb2dfd/05f55ebb-7310-42c2-a638-cceb8fcb2dfd1.gif)
![Chapter3_6e.doc_第2頁](http://file.renrendoc.com/FileRoot1/2020-1/9/05f55ebb-7310-42c2-a638-cceb8fcb2dfd/05f55ebb-7310-42c2-a638-cceb8fcb2dfd2.gif)
![Chapter3_6e.doc_第3頁](http://file.renrendoc.com/FileRoot1/2020-1/9/05f55ebb-7310-42c2-a638-cceb8fcb2dfd/05f55ebb-7310-42c2-a638-cceb8fcb2dfd3.gif)
![Chapter3_6e.doc_第4頁](http://file.renrendoc.com/FileRoot1/2020-1/9/05f55ebb-7310-42c2-a638-cceb8fcb2dfd/05f55ebb-7310-42c2-a638-cceb8fcb2dfd4.gif)
![Chapter3_6e.doc_第5頁](http://file.renrendoc.com/FileRoot1/2020-1/9/05f55ebb-7310-42c2-a638-cceb8fcb2dfd/05f55ebb-7310-42c2-a638-cceb8fcb2dfd5.gif)
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
Test Bank for Problem Solving with C+: The Object of Programming, 6/e Chapter 3 More Flow of ControlTRUE/FALSE1. A boolean expression may evaluate to more than 2 valuesANSWER: FALSE2. A function may return a boolean value.ANSWER: TRUE3. In an enumerated data type, different constants may not have the same value.ANSWER: FALSE4. The compiler always pairs an else with _ANSWER: the nearest previous if not already paired with an else.5. All switch statements can be converted into nested if-else statementsANSWER: TRUE6. All nested if-else statements can be converted into switch statements.ANSWER: FALSE7. A break statement in a switch stops your program.ANSWER: FALSE8. It is illegal to make function calls inside a switch statement.ANSWER: FALSE9. A semicolon by itself is a valid C+ statement.ANSWER: TRUE10. The break statement causes all loops to exit.ANSWER: FALSEShort Answer1. A _ expression is an expression that can be thought of as being true or false.ANSWER: boolean2. _ is a type whose values are defined by a list of constants of type int.ANSWER: enumerated data type3. The code following the _ case is executed if none of the other cases are matched in a switch statement.ANSWER: default4. A compound statement that contains variable declarations is called a _.ANSWER: block5. Variables defined inside a set of braces are said to be _ to that block of code.ANSWER: local6. Each repetition of a loop body is called _.ANSWER: an iteration7. A _ loop always executes the loop body at least once, irregardless of the loop condition.ANSWER: do-while8. A switch statement variable must be _ANSWER: an integer, bool, char or enumerated type9. A loop that iterates one too many or one too few times is said to be _ANSWER: off by oneMultiple Choice1. Which boolean operation is described by the following table?ABOperationTrueTrueTrueTrueFalseTrueFalseTrueTrueFalseFalseFalsea. orb. andc. notd. none of the aboveANSWER: A2. Which boolean operation is described by the following table?ABOperationTrueTrueTrueTrueFalseFalseFalseTrueFalseFalseFalseFalsea. orb. andc. notd. none of the aboveANSWER: B3. Which of the following symbols has the highest precedence?a. +b. |c. &d. -ANSWER: A4. If a programming language does not use short-circuit evaluation, what is the output of the following code fragment if the value of myInt is 0?int other=3, myInt;if(myInt !=0 & other % myInt !=0)cout other is oddn;elsecout other is evenn;a. other is evenb. other is oddc. 0d. run-time error, no outputANSWER: D5. What is the value of the following expression?(true & (4/3 | !(6)a. trueb. falsec. 0d. illegal syntaxANSWER: A6. if x is 0, what is the value of (!x =0)?a. falseb. truec. unable to determined. AANSWER: A7. Which of the following are equivalent to (!(x=3)?a. (x15 & y=15 & y =15 | y 15 | y 3)e. C and DANSWER: C8. Which of the following boolean expressions tests to see if x is between 2 and 15 (including 2 and 15)?a. (x=2)b. (2 =x | x =2 & x =15)d. (2 = x = 15)ANSWER: C9. Given the following enumerated data type definition, what is the value of SAT?enum myTypeSUN,MON,TUE,WED,THUR,FRI,SAT,NumDays;a. 7b. 6c. 8d. 5e. unknownANSWER: b10. Given the following enumerated data type definition, what is the value of SAT?enum myTypeSUN=3,MON=1,TUE=3,WED,THUR,FRI,SAT,NumDays;a. 7b. 6c. 8d. 5e. unknownANSWER: A11. What is the output of the following code fragment if x is 15?if(x 20)if(x 10)cout less than 10 ;elsecout largen;a. less than 10b. nothingc. larged. no output, syntax errorANSWER: C12. What is the output of the following code fragment?int i=5;switch(i)case 0:i=15;break;case 1:i=25;break;case 2:i=35;break;case 3:i=40;default:i=0;cout i endl;a. 15b. 25c. 35d. 40e. 0f. 5ANSWER: E13. What is wrong with the following switch statement?int ans;cout ans;switch (ans)case y: case Y: cout You said yesn; break;case n:case N: cout You said non; break;default: cout invalid answern;a. ans is a intb. break; is illegal syntaxc. nothingd. there are no break statements on 2 cases.ANSWER: A14. Which of the following data types can be used in a switch controlling expression?a. intb. charc. floatd. enume. doublef. d and eg. a and bh. a,b and di. all of the aboveANSWER: H15. What is the output of the following code fragment?int x=0;int x=13;cout x ,;cout x endl;a. 13,13b. 0,13c. 13,0d. nothing, there is a syntax error.ANSWER: C16. What is the output of the following code fragment?int x=13;cout x ,;cout x 10)x =13;a. 10b. 9c. 13d. 11ANSWER: A18. What is the value of x after the following code executes?int x=10;if( +x 10)x =13;a. 10b. 9c. 13d. 11ANSWER: C19. How many times is Hi printed to the screenfor(int i=0;i14;i+);cout Hin;a. 13b. 15c. 14d. 1ANSWER: D20. Given the following code, what is the final value of i?int i;for(i=0; i=4;i+)cout i endl;a. 3b. 4c. 5d. 0ANSWER: C21. Given the following code, what is the final value of i?int i,j;for(i=0;i4;i+)for(j=0;j3;j+)if(i=2)break;a. 3b. 4c. 5d. 0ANSWER: B22. Which of the following is not a good reason for choosing a certain loop control?a. What the loop doesb. The minimum number of iterations of the loopc. The condition for ending the loopd. If the loop is in a functionANSWER: D23. If you want a loop to quit iterating if x 3, what would be the proper loop condition test?a. (x 3)b. (x 10 | y =10 & y =10 | y =3)ANSWER: D24. If you need to write a do-while loop that will ask the user to enter a number between 2 and 5 inclusive, and will keep asking until the user enters a correct number, what is the loop condition?a. (2=num=5)b. (25number)c. (2 = number & number = 5)d. (2 5)e. (2 number & number 5)ANSWER: D25. Which loop structure always executes at least once?a. do-whileb. forc. whiled. sentinelANSWER: A26. Which of the following are allowed in the third section of the for loop statement?a. i+b. i-c. i +=2d. cout Hellone. all of the abovef. none of the aboveANSWER: E27. Which of the following data types may be used in a sw
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度新能源汽車充電樁建設合同協(xié)議范本
- 2025年度家庭土地承包經營合同示范文本
- 2025年度基礎設施建設項目施工專業(yè)分包合同書
- 2025年度高層建筑安全設計與評估建筑師聘用合同
- 2025年度建筑抗震性能檢測與加固設計合同
- 2025年度智能電網(wǎng)運維技術服務合同
- 2025年文化創(chuàng)意產業(yè)顧問服務合同范本
- 2025年度物聯(lián)網(wǎng)控制器采購合同范本
- 2025年度空壓機租賃與設備租賃合同續(xù)簽管理協(xié)議
- 2025年度能源項目國有土地租賃合同標準范本
- 2024年包頭市水務(集團)有限公司招聘筆試沖刺題(帶答案解析)
- 知識庫管理規(guī)范大全
- 2024年贛州民晟城市運營服務有限公司招聘筆試參考題庫附帶答案詳解
- 領導干部報告?zhèn)€人事項
- 9這點挫折算什么(課件)-五年級上冊生命與健康
- 價格監(jiān)督檢查知識培訓課件
- 駐場保潔方案
- 中國心理衛(wèi)生協(xié)會家庭教育指導師參考試題庫及答案
- 智能廣告投放技術方案
- 知識產權保護執(zhí)法
- 高質量社區(qū)建設的路徑與探索
評論
0/150
提交評論