




已閱讀5頁(yè),還剩3頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 廣東中職考試題庫(kù)及答案
- 右三踝骨折護(hù)理查房
- 自發(fā)性氣胸的護(hù)理措施
- 4S店車間生產(chǎn)安全培訓(xùn)
- 銀行員工之聲培訓(xùn)課件
- 腫瘤護(hù)理發(fā)展趨勢(shì)
- 養(yǎng)老機(jī)構(gòu)安全培訓(xùn)
- 中班語(yǔ)言彩色奶牛課件
- 圖形認(rèn)知培訓(xùn)課件
- 鉆孔灌注樁培訓(xùn)課件
- GB/T 19879-2005建筑結(jié)構(gòu)用鋼板
- GB 6245-1998消防泵性能要求和試驗(yàn)方法
- 酒店會(huì)議協(xié)議書(shū)(4篇)
- 高血糖高滲狀態(tài)課件
- 一年級(jí)10以內(nèi)加減混合計(jì)算題比大小
- 閑置資源統(tǒng)計(jì)表
- 畫(huà)冊(cè)設(shè)計(jì)制作報(bào)價(jià)單
- DBJ∕T13-354-2021 既有房屋結(jié)構(gòu)安全隱患排查技術(shù)標(biāo)準(zhǔn)
- 某市印染紡織公司清潔生產(chǎn)審核報(bào)告全文
- 維修電工高級(jí)技師論文(6篇推薦范文)
- 人民幣教具正反面完美打印版
評(píng)論
0/150
提交評(píng)論