S10Final - University of Waterloo Final Examination Term:...

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

View Full Document Right Arrow Icon
Term: Spring Year: 2010 Student Name: ________________________________________ Student ID Number: ___________________________________ Course Abbreviation and Number GENE 121 (Mech Eng C++/RobotC) Course Title Digital Computation Section(s) 001 Instructor Rajnish Bassi Date of Exam August 7, 2010 Time Period Start time: 9:00 am End time: 11:30am Duration of Exam 2.5 hrs Number of Exam Pages 12 (including this cover sheet) Exam Type Special Materials Additional Materials Allowed ONE (8.5X11) formula sheet Writing instruments Notes: No electronic devices including NO CALCULATORS You can assume for any program that any necessary #include s have been written. If you need to make any assumption to formulate your solution, state your assumptions clearly. Answer all questions in the space provided. If you require additional space, write on the back of the opposite page and indicate this clearly. Unless specified in the question, you do not need to include error checking. Marking Scheme: Question Maximum Marks Mark 1 10 2 10 3 20 4 10 5 25 6 25 Total 100 University of Waterloo Final Examination
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 2 of 12 1. Short Answer [10 marks] a) [4Marks] Answer true (T) or false (F) for each of the following ____ declaring arrays with more than two dimensions results in compile-time error ____ all C++ operators are evaluated from left to right ____ parameters passed by value to a function are considered as local variables ____ theoretically, ultrasonic sensor can detect obstacles within the range of 0-255 cm b) [3 Marks] What will be the output? int valRef (int &i, int j, int &k) { i = j * k; return ++j; } int valRef (int &i, int &j, double k) { i = j * k; return ++j; } int main() { int i, j = 2; double k = 2; i = valRef (j, j, k); cout << i << j; i = valRef (j, j, j); cout << i << j; return 0; }
Background image of page 2
Page 3 of 12 c) [3 marks] What will be the output? int main() { int a[5] = {3, 5, 3, 6}, b = 2, c = 3; int *q = &b; *q = *(a+1)**q; c = (*a+1)**q; cout << b << " " << c ; return 0; } 2. Functions [10 marks] Write a function that receives an array of integers sorted in ascending order, the number of array elements, and another integer. The function must insert the integer into the
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 note was uploaded on 04/01/2012 for the course GENE 121 taught by Professor Smucker during the Winter '11 term at Waterloo.

Page1 / 12

S10Final - University of Waterloo Final Examination Term:...

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