免费预览已结束,剩余4页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Test Bank for Problem Solving with C+: The Object of Programming, 6/e Chapter 2 C+ BasicsTRUE/FALSE1. In the following code fragment, x has the value of 3.int x = 3;ANSWER: TRUE2. The body of a do-while loop always executes at least once.ANSWER: TRUE3. The body of a while loop may never execute.ANSWER: TRUE4. The opposite of (x 3 & x 10) is (x 10)ANSWER: FALSE5. The integer 0 is considered true.ANSWER: FALSE6. Loops are used when we need our program to make a choice between two or more things.ANSWER: FALSE7. It is legal to declare more than one variable in a single statement.ANSWER: TRUE8. Variable names may begin with a number.ANSWER: FALSE9. The opposite of less than is greater thanANSWER: FALSE10. Every line in a program should have a comment.ANSWER: FALSEShort Answer1. is called the _ operator.ANSWER: insertion2. The braces for a loop define the _ of the loop.ANSWER: body3. A loop that always executes the loop body at least once is known as a _ loop.ANSWER: do-while4. int myValue; is called a _.ANSWER: variable declaration5. What is the opposite of ( x 12)? _ANSWER: (x =20 | x 19 & x is known as the _ operator.ANSWER: extraction10. Is used for input or output? _ANSWER: output11. The stream that is used for input from the keyboard is called _.ANSWER: cin12. The stream that is used for output to the screen is called _.ANSWER: cout13. Write the loop condition to continue a while loop as long as x is negative. _ANSWER: while(x 0)14. When must we use braces to define the body of a contitional expression? _ANSWER: When there are multiple statements in the body.15. In a compound logical and (&) expression, the evaluation of the expression stops once Page: 2true only for &, not for | where it looks for true not falseone of the terms of the expression is false. This is known as _ evaluation.ANSWER: short-circuit evaluationPage: 2I added the (&) to the questionMultiple Choice1. Which of the following is a valid identifier?a. 3comb. three_comc. 3_comd. 3-come. dollar$ANSWER: C (should be B)2. Which of the following is not a valid identifer?a. returnb. myIntc. myIntegerd. total3ANSWER: A3. What is the value of x after the following statements?int x, y, z;y = 10;z = 3;x = y * z + 3;a. Garbageb. 60c. 30d. 33ANSWER: D4. What is the value of x after the following statements?int x;x = 0;x = x + 30;a. 0b. 30c. 33d. garbageANSWER: B5. What is the value of x after the following statements?int x;x = x + 30;a. 0b. 30c. 33d. garbageANSWER: D6. What is the output of the following code?float value;value = 33.5;cout value endl;a. 33.5b. 33c. valued. garbageANSWER: A7. What is the output of the following code?float value;value = 33.5;cout value endl;a. 33.5b. 33c. valued. garbageANSWER: C8. What is the output of the following code?cout This is a myFloat;b. cin myFloat;d. cin myFloat endl;ANSWER: A10. Another way to write the value 3452211903 isa. 3.452211903e09b. 3.452211903e-09c. 3.452211903x09d. 3452211903e09ANSWER: A11. Which of the following statements is NOT legal?a. char ch=b;b. char ch=0;c. char ch=65;d. char ch=cc;ANSWER: D12. What is the value of x after the following statements?float x;x = 15/4;a. 3.75b. 4.0c. 3.0d. 60ANSWER: C13. What is the value of x after the following statements?int x;x = 15/4;a. 15b. 3c. 4d. 3.75ANSWER: B14. What is the value of x after the following statements?int x;x = 15 %4;a. 15b. 4c. 3d. 3.75ANSWER: C15. What is the value of x after the following statement?float x;x = 3.0 / 4.0 + 3 + 2 / 5 a. 5.75 b. 5.75c. 1.75d. 3.75ANSWER: D16. What is the value of x after the following statement?float x;x = 3.0 / 4.0 + (3 + 2 )/ 5 a. 5.75 b. 5.75c. 1.75d. 3.75ANSWER: C17. What is the value of x after the following statements?double x;x = 0;x += 3.0 * 4.0;x -= 2.0;a. 22.0b. 12.0c. 10.0d. 14.0ANSWER: C18. Given the following code fragment and the input value of 4.0, what output is generated?float tax;float total;cout total;if ( total = 3.0)tax = 0.10;cout total + (total * tax) endl;elsecout total endl;a. 3b. 3.3c. 4.0d. 4.4ANSWER: D19. Given the following code fragment and the input value of 2.0, what output is generated?float tax;float total;cout total;if ( total = 3.0)tax = 0.10;cout total + (total * tax) endl;elsecout total endl;a. 2.2b. 2.0c. 3.1d. 4.4ANSWER: B20. If x has the value of 3, y has the value of -2, and w is 10, is the following condition true or false?if( x 2 & w y)a. trueb. falseANSWER: B21. What is the correct way to write the condition y x z?a. (y x z)b. ( (y x) | (y z)d. (y x) & (x z)ANSWER: D22. Given the following code fragment, and an input value of 3, what is the output that is generated?int x;cout x;if(x=0)cout x is zeron;elsecout x is not zeron;a. x is zerob. x is not zeroc. unable to determined. x is 3ANSWER: A(note it is an assignmentPage: 6But the answer is the same as if you used = instead of =. Maybe an input of 0?Page: 6I had witten the wrong answer! It will always print out x is zero!)23. Given the following code fragment, and an input value of 5, what is the output?int x;if( x 3)cout smalln;elseif( x 4)cout mediumn;elseif( x 6)cout largen;elsecout 5)cout x is bigger than 5. ;cout That is all. ;cout Goodbyen;a. x is bigger than 5. That is allb. x is bigger than 5c. That is all. Goodbyed. GoodbyeANSWER: C25. Executing one or more statements one or more times is known as:a. selectionb. iterationc. sequenced. algorithmANSWER: B26. Given the following code fragment, what is the final value of y?int x, y;x = -1;y = 0;while(x = 3)y += 2;x += 1;a. 2b. 10
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 长治市潞城市2025届三年级数学下学期期中学业水平测试试题(含解析)
- 长沙市浏阳市2025届数学三下期中达标测试试题(含解析)
- 长武县2025届四年级数学第一学期阶段统考模拟试题含解析
- 电器设备公司生产总监述职报告
- 2026年统编版一年级下册语文期末复习必背知识点讲义
- 滨州安培试题及答案
- 农业行业面试题及答案
- 《弯道超车》2024年人教版新八年级生物暑假提升讲义 第12讲 传染病及其预防(原卷版)
- 某麻纺厂成本控制措施制度
- 某服装厂质量控制细则
- 2026年无人机驾驶证通关题库及答案详解(典优)
- (2026年)萍乡市莲花县辅警考试公安基础知识考试真题库及参考答案
- 铝合金牺牲阳极的国家标准与行业规范
- 2026年高中政治教师招聘经典试题及答案
- RTCA∕DO-160G 机载设备环境条件和试验程序
- 客户服务管理员题库(附答案)
- 办公室装修工程施工现场临时用电方案
- 人教版小学一年级数学下册各单元练习题
- 安徽省合肥一中、安庆一中等六校2026届高一下生物期末复习检测试题含解析
- 2025年录音师考试《同期录音》技巧
- 2026高压电工证资格考试核心题库(答案及解析)
评论
0/150
提交评论