cs10_07spr_samplefinal_sol

cs10_07spr_samplefinal_sol - Last name: _ SID (last 4...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Last name: _____________________ First name: ___________________________ SID (last 4 digits): __________ login id: __________ CS 010 – Intro to Computer Science I Spring - 2007 Sample Final exam - total 100 points SOLUTION Time: 3 hours You may have on your desks ONLY this exam, your personalized multiple choice answer sheet, a writing implement and an eraser, and your student ID. You may use a separate sheet(s) of scratch paper. Make good use of this – don’t write your answers in the assigned space until you are sure of them! WRITE CLEARLY IN THE SPACE PROVIDED. WARNING !!!: POINTS WILL BE DEDUCTED FOR MESSY & HARD-TO-READ HANDWRITING!!! Section I (questions 1 to 25) are to be answered on your multiple choice answer sheets; Section II (questions 1 to 5) on this exam booklet. Hand both in together. You will be required to show your student ID when you hand in your exam. Be sure to read each problem carefully and follow the directions. Section I 25 Section II Q.1 15 Section II Q.2 15 Section II Q.3 15 Section II Q.4 15 Section II Q.5 15 TOTAL 100
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Last name: _____________________ First name: ___________________________ Section I: Multiple choice – 1 point each 1. Which of the following is NOT a valid assignment statement? a. product = n * m; b. n + m = sum; c. result = result + 5; d. 5 = n – m; e. f. 2. Which of the following data types is not “built into” the core C++ language? a. int b. string c. double d. char e. bool 3. What is output to the screen with the following statements? string name = “Johnson”; cout << name.substr(4, 3); a. Johnson b. John c. son d. nso 4. What is the output of the following code fragment? cout << fixed << setprecision(1) << setw(4) << 1.234 << endl << setw(4) << 12.34 << endl; a. 1.23 12.3 b. 1.234 12.34 c. 1.234 12.34 d. 1.2 12.34 e. 1.2 12.3 5. The value of the expression ( 20.0 * (9/5) ) + 32.0 is: a. 68.0 b. 93.6 c. 32.0 d. 52.0 e. this is a mixed-type expression, so it will not compile 2
Background image of page 2
Last name: _____________________ First name: ___________________________ 6. getline( istream, string_variable ) is a function provided by the string library to work with input stream objects such as cin . The effect of the instruction getline( cin, abc ); //where abc is a valid string variable is: a. to populate the string abc with the entire line entered at the keyboard, up to the newline character b. to populate the string abc with the next character in the input stream buffer c. to return the number of characters currently in the input stream buffer as an int d. to return a bool indicating whether the end of file has been reached e. the same as cin >> abc; 7. in a while or a for loop, the condition is evaluated: a. each time the counter is incremented b. only if it is True c. the same number of times as the loop body is executed d. once less than the number of times the loop body is executed e. once more than the number of times the loop body is executed 8. A definition of a variable outside any function is a:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This test prep was uploaded on 04/15/2008 for the course CS 10 taught by Professor Linard during the Spring '07 term at UC Riverside.

Page1 / 12

cs10_07spr_samplefinal_sol - Last name: _ SID (last 4...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online