《C面向对象程序设计考试题库.docx》由会员分享,可在线阅读,更多相关《C面向对象程序设计考试题库.docx(136页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、SHORT ANSWER1. Aset of instructions that the computer will follow is called a. Answer: program2. The collection of programs used by the computer is known as. Answer: software3. Computers that are interconnected are known as a. Answer: network4. A digit that can hold a zero or a one is known as a. An
2、swer: bit5. List at least two input devices. Answer: keyboard, mouse, network card, file6. List at least two output devices. Answer: screen, printer, file, network card7. A variable that can hold a whole number is called a(n). Answer: integer8. What punctuation signifies the end of a C+ statement? A
3、ns we 亡 A semicolon.9. A mistake in a computer program is called a. Answer: bug10. A is the program that translates a program written in C+ into machine language.Answer: compiler11. Errors in a program can be classified into three types, list them Answer: Syntax, logic,run-time12. What does the foll
4、owing statement in C+ print to the screen? cout ”Hello studentsnM;Answer: Hello students.13. A mistake that is a direct violation of the syntax rules will generate a compiler. Answer: error14. If your program compiles and runs, but gives an incorrect output, this is known as a error.Answer: logic15.
5、 The part of the computer that controls and executes programs is called the. Answer: CPUMULTIPLE CHOICE1. Who was the programmer for Charles Babbages analytical engine?a. Grace Hopper b. Ada Lovelace c. Lord Bryan d. Walter SavitchAnswer: Ba. The inputs and outputs of a programb. The part of the com
6、puter that does the processingc. A finite set of steps to solve a problemd. A complete computer programAnswer: C3.A memory address isa. Where a variable is storedb. Where the computer is locatedc. A step in the program.d. Where the CPU is stored.Answer: A4.A computer that is normally used by only on
7、e person at a time is called aa. Serverb. Mainframec. Personal Computerd. NetworkAnswer: C5.The physical machines that make up a computer is called thea. Softwareb. Networkc. Devicesd. CPUe. HardwareAnswer: E6.Which of the following is not a phase of the program-design process?a. Problem-solvingb. I
8、mplementationc. Marketing the final programAnswer: C7.Which of the following is not part of the Software Life Cycle?a. Analysisb. Designc. Data Entryd. Implementatione. TestingAnswer: C8.From which language did C+ directly evolve?a. Ab. Adac. Cd. C+e. C-Answer: C9.What does the following line of cod
9、e display to the screen?cout ”This is the computern programming bookn;a. This is the computem programming bookb. This is the computerc. Nothingd. This is the computer programming bookAnswer: D2.An algorithm is10. C+ statements end with aa. Periodb. Commac. Semicolond. NothingAnswer: C11. Which of th
10、e following is not an example of a program bug?a. Run-time errorb. Operator errorc. Syntax errord. Logic errorAnswer:B12. What does the following code print to the screen?cout vv “hello”;a. Hellob. helloc. HELLOd. NothingAnswer: B13. The set of instructions that a computer will follow is known as:a.
11、 Hardwareb. Algorithmc. Programd. CPUAnswer: C14. The anagram CPU stands fora. Computer Programming Unitb. Central Processing Unitc. Central Program Userd. Computer Paper UserAnswe亡 B15. The output of the compiler is calleda. The programb. Source codec. Linked coded. Object codeAnswer:D16. The term
12、OS stands fora. Operating Systemb. Oscillating Systemc. Operations Servicesd. NothingAnswer: A17. Who designed the first programmable computer?a. IBMb. Microsoftc. Inteld. Babbagee. DellAnswer: D18. A finite sequence of precise instructions that leads to a problem solution isa. A programb. The CPUc.
13、 A List of Inputs and Outputsd. An AlgorithmAnswer: D19. Who developed C+?a. Bjarne Stroustrup b. Ken Thompsonc. Charles Babbage d. Ada LovelaceAnswer: A20. One of the biggest difference between C and C+ is:a. C is object-orientedb. C+ is object-orientedc. All C+ programs are also C programsd. C onl
14、y runs on UNIX computersAnswer: B21. int number;a. is an output statementb. is an input statementc. is a variable declarationd. is a programAnswer: C22. cout ”How many items would you want?n;a. is an output statementb. is an input statementc. is a variable declarationd. is a programAnswer: A23. cin
15、number;A is an output statementB is an input statementC is a variable declarationD is a programAnswer: B23. What does the following print to the screen? cout Hello Students/n”;a. Hello Studentsb. hello Studentsc. HELLO STUDENTSd. Hello Students/nAnswer:D24. #include a. is a variable declaration b. a
16、n executable statement c. an include directived. illegal codeAnswer: C25.A byte consists of how many bits?a. 6b. 7c. 8d. 9e. 10Answer: C26. What is wrong with the following statement?cout ”Hello to everyonena. cout should be countb. missing a semicolonc. missing a d. missing a (Answer: B27. What is
17、wrong with the following statement?cout Hello to everyonen;a. cout should be countb. missing a semicolonc. missing a d. missing a (Answer: C28. C+ is an example of aa. Machine languageb. High-level languagec. Low-level languaged. Assembly languageAnswer: B29. RAM stands fora. Read access memoryb. Ra
18、ndom access memoryc. Really atrocious memoryd. A hard driveAnswer: BTRUE/FALSE1. Grace Hopper discovered the first documented computer bug.Answer: TRUE2. The following statement is legal: cout Hello, my name is Billn”;Answer: FALSE3. You should write your program before you write the algorithm.Answe
19、r: FALSE4. It is considered better style to put the braces () on separate lines. Answer: TRUE5. The compiler will catch all your programming mistakes.Answer: FALSE6. C+ is a low-level language.Answer: FALSE7. Main memory holds its data if the computer is turned offAnswer: FALSE8. An algorithm is alw
20、ays written in C+Answer: FALSE9. There are 8 bytes in one bit. Answer: FALSE10. The printer is an example of an input device.Answer: FALSETRUE/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: TRUE
21、3. 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 on
22、e 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
23、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 II x 19 & x 99)7. Each time a loop body executes is known as an.
24、ANSWER: iteration8. if-else statements that are inside other if-else statements are said to be. ANSWER: nested9. 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 i
25、s 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 my Float;b. cin myFloat;c. cin myFloat;d. cin myFloat endl;ANSWER:A10. Another way to write the value 3452211903 isa. 3.452211903e09b. 3.452211903e-09
26、c. 3.452211903x09d. 3452211903e09ANSWER: A11. Which of the following statements is NOT legal?a. char ch二b;b. char ch:;c. char ch=65;d. char ch二“cc”;ANSWER: D12. What is the value of x after the following statements?float x;x 二 I5/4;a. 3.75b. 4.0c. 3.0d. 60ANSWER: C13. What is the value of x after th
27、e following statements?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/5a. 5.75b. 5.75c. 1.75d. 3.75ANSWER: D16. What is the v
28、alue of x after the following statement?float x;x 二 3.0/4.0 + (3 +2)/5a. 5.75b. 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
29、of 4.0, what output is generated? float tax;float total;cout ”enter the cost of the itemn;cin total;if (total = 3.0)(tax = 0.10;cout total + (total * tax) endl; else ( cout 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 gen
30、erated? float tax;float total;cout enter the cost of the itemn;cin total;if (total = 3.0)tax = 0.10;cout total + (total * tax) endl;)elsecout total end);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
31、& 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) II (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 uEnter a valuen;cin x;if(x=0)(cout ”x is zeronK;)
32、else(cout ”x is not zeron;)a. x is zerob. x is not zeroc. unable to determined. x is 3ANSWER: A (note it is an assignment!)23. Given the following code fragment, and an input value of 5, what is the output?int x;if( x 3)cout nsmallnH;else(if( x4)cout ”mediumn;) elseif( x 5)cout ”x is bigger than 5.c
33、out nThat is all.M;cout ”Goodbye;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
34、the final value of y?int x, y;a. = -1;b. = 0;while(x = 3)(y+= 2; x += 1;)c. 2d. 10e. 6d. 8ANSWER: B27. Given the following code fragment, what is the final value of y?int x, y;a. = -1;b. = 0;while(x 3)(y += 2;X += 1;)c. 2d. 10e. 6f. 8ANSWER: D28. What is the output of the following code fragment?int
35、 x=0;while( x 0);a. 8b. 9c. 10d. 11e. infinite loopANSWER: E30. Given the following code fragment, which of the following expressions is always true? int x;cin x;a. if( x l )d. if(x= 1)ANSWER: DTRUE/FALSE1. A boolean expression may evaluate to more than 2 values ANSWER: FALSE2. A function may return
36、 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 withANSWER: the nearest previous if not already paired with an else.5. All switch statements can be converted into nested if-else statements
37、ANSWER: 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:
38、 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 th
39、e 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: