finw2011 - 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: Winter Year: 2011 Student Name ______________________________________________________________________ Signature: ___________________________________________________________________________ UW Student Number: ________________________________ SUPP/DEFERRED EXAM _______ Course Abbreviation and Number GEN E 121 (Mech Eng C++/RobotC) Course Title Digital Computation Section(s) 001 Instructor C. Hulls Date of Exam Saturday April 16, 2010 Time Period Start time: 9:00a.m. End time: 11:30a.m. Duration of Exam 2.5 hours Number of Exam Pages (including this cover sheet) 9 Exam Type Special Materials Additional Materials Allowed ONE 8.5 inch x11 inch sheet marked on BOTH sides Notes: No electronic devices including NO CALCULATORS You can assume for any programs that any necessary #include s have been written. If you need to make any assumptions 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. Questions are to be answered using C++ except where indicated as RobotC using Marking Scheme: Question Maximum Mark Mark 1. 10 2. 10 3. 12 4. 28 5. 30 Total 90 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
ID___________________________ Mech Eng GENE 121 (C++/RobotC) Page 2 of 9 1. Short Answer [10 Marks] (a) [3 Marks] Complete the statements below. i. double a[10] declares an array of size _________. ii. 11001 in binary is ______ in base 10. iii. time100[1] measures elapsed time in _______________________. (b) [3 Marks] What is output by void f(int* p1, int* p2) { if (*p1 < *p2) *p1 *= 2; else *p2 = 1; } int main() { int x = 3, y = 4; f(&x,&y); cout << x << "," << y << endl; int* p1 = &x; int* p2 = p1; f(p1,p2); cout << x << "," << y << endl; return 0; } (c) [4 Marks] What is output by int mixer(int & a, int & b, int c) { c *= a; b = a++; return c; } int main() { int a = 3, b = -4, c = 1; cout << mixer(b,c,b) << endl << a << endl << b << endl << c << endl; return 0; }
Background image of page 2
ID___________________________ Mech Eng GENE 121 (C++/RobotC) Page 3 of 9 2. Errors [10 Marks] (a) [6 Marks] The code below has six errors. Identify them, and indicate how you would correct them. Marks will be deducted for incorrectly identified errors. The code converts polar coordinates (r, θ) to Cartesian coordinates (x, y). void polar2cart(double
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 / 9

finw2011 - 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