cs12_05win_final_sol

cs12_05win_final_sol - Last name: _ First name: _ SID (last...

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 012 – Intro to Computer Science II Winter - 2005 Final exam – Friday 3/18 – 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 points each 1. In C++, a variable of one of the built-in data types which has been defined but not initialized will be: a. set to zero by the compiler b. set to a random number between 1 and 100 c. usable only as the destination (left-hand argument) for an assignment expression d. available for immediate use in any expression e. flagged by the compiler as an error 2. The syntactically correct way (in standard C++) to declare and initialize, in a single step, a pointer to a previously declared variable s, of type double, is a. double* p = &s; b. double &p = *s; c. double* p = s; d. double p = *s; e. double* p = *s; 3. After the following statements are executed, what can be said about variables x and p? char x = ‘M’; char* p = &x; *p = ‘W’; a. p holds the value ‘M’. b. p holds the value ‘W’. c. p points to the variable x, which has the value ‘M’ d. p points to the variable x, which has the value ‘W’ e. p holds the value ‘W’, x holds the value ‘M’ f. The statements cannot be executed because of a compiler error. 4. If p1 and p2 are pointers to two different variables v1 and v2 of the same type, with p1 pointing to v1 and p2 pointing to v2, then which of these statements is correct? a. *p1 = *p2; makes the value of p1 equal to the value of p2. b. *p1 = *p2; makes the value of v2 equal to the value of v1. c. *p1 = *p2; makes the value of p2 equal to the value of p1. d. *p1 = *p2; makes the value of v1 equal to the value of v2. e. None of the above. 2
Background image of page 2
Last name: _____________________ First name: ___________________________ 5. Given that int* p; declares a pointer to an integer, which of the following is not correct: a. *p = 7; is a valid C++ statement. b.
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.

Page1 / 16

cs12_05win_final_sol - Last name: _ First name: _ SID (last...

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