midterm2002_fall_A_sol

midterm2002_fall_A_sol - 28 October, 2002 ` COMP 102 -...

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

View Full Document Right Arrow Icon
28 October, 2002 COMP 102 -- Midterm Exam Version A Solution Page 1 of 12 ` THE HONG KONG UNIVERSITY OF SCIENCE AND TECHNOLOGY Department of Computer Science COMP 102: Computer and Programming Fundamentals I Fall 2002 Midterm Examination (All Sections) Date: 28 October, 2002 This exam contains 11 questions on 12 pages. Please count the pages. You have 2 hours to complete this exam. Instructions 1. This is a closed-book, closed-notes examination. 2. Check that you have all 12 pages (including this cover page). 3. Write your name, student number, lecture and lab sections on this page. 4. Answer all questions in the box provided using a ball point pen. 5. Please turn off your mobile phone/pager or else you will be disqualified. 6. No electronic devices (including calculators, PDA, dictionaries, etc.) Problem Your point s Max point s Problem Your point s Max point s 1 5 7 6 2 10 8 5 3 20 9 8 4 5 10 10 5 7 11 12 6 12 Subtotal 59 Subtotal 41 Your total points 100 Please identify yourself: Lab section Name Student Id Signature
Background image of page 1

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

View Full DocumentRight Arrow Icon
28 October, 2002 COMP 102 -- Midterm Exam Version A Solution Page 2 of 12
Background image of page 2
28 October, 2002 COMP 102 -- Midterm Exam Version A Solution Page 3 of 12 (5 points) Which of the following lines contains a valid C++ identifier? (Write True or False in the corresponding boxes). A. UST CU B. UST_CU D. 1USTCU E. USTCU1 2. (10 points) Given int distance = 2, v = 50, n= 10, t = 1; What is the value of each of the following expressions? a) n/t+3 _____________13_______________ b) v / t + n – n* distance ______________40______________ c) v – 3 * n + 4 * distance ______________28______________ d) distance /5 ______________0______________ e) (v + n)/ (t + distance) ______________20______________ f) v + n / t + distance ______________62______________ g) 3 * v/4%5 && --distance _______________true_____________ h) v || n <=(t + 15) && t /n _______________true_____________ i) !(4 + 5 * v>= n –4) || (t –8) _______________true_____________ j ) (v / n ) && (t-- == 0) _______________false__________ False True False True False
Background image of page 3

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

View Full DocumentRight Arrow Icon
28 October, 2002 COMP 102 -- Midterm Exam Version A Solution Page 4 of 12 3. (20 points total) a) (2 points) What is the output from the following block of code? int x, y = 0;
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

midterm2002_fall_A_sol - 28 October, 2002 ` COMP 102 -...

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

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