Midterm Exam

Midterm Exam - Midterm Examination Winter TERM 2009...

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

View Full Document Right Arrow Icon
Midterm Examination Winter TERM 2009 Computer Science 246 Software Abstraction and Specification Sections 01 Duration of Exam: 110 minutes Number of Exam Pages (including cover sheet): 3 Total number of questions: 8 Total marks available: 72 CLOSED BOOK, NO ADDITIONAL MATERIAL ALLOWED Instructor: Ric Holt February 26, 2009 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Midterm Exam – CS 246 (W09) 2 1. (a) 1 mark True or False : After executing the following code in a function, the output produced is necessarily 0 (zero). int j; cout << j; (b) 1 mark True or False : The following code causes 0 (zero) to be printed. int x = 0; if ( x = 0 ) cout << x; else cout << 10; (c) 3 marks Re-write the following code so it uses a while loop (not a do - while loop) instead of a for loop. int i; for ( i = 0; i < LIMIT; i += 1 ) cout << i << endl; (d) 3 marks Write a switch statement that prints the string "zero" when variable i is 0, the string "five" when i is 5, and otherwise prints the string "No go" . 2.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2012 for the course CS 246 taught by Professor Wormer during the Winter '08 term at Waterloo.

Page1 / 3

Midterm Exam - Midterm Examination Winter TERM 2009...

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

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