final_S11_soln

# final_S11_soln - Term Spring Year 2011 Student Name UW...

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

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Term: Spring Year: 2011 Student Name: ______________________________________________________________________ UW Student ID Number: ______________________________________________________________ I understand that the contents of this exam paper are to remain confidential until Friday July 5, 2011. Failure to do so constitutes an academic offence under UW Policy 71. Signature: __________________________________________________________________________ Course Abbreviation and Number GEN E 121 (ME C++/RobotC) Course Title Digital Computation Section(s) 001 Instructor Ryan Norris Date of Exam Saturday, August 6, 2010 Time Period Start time: 12:30pm End time: 3:00pm Duration of Exam 2.5 hours Allowed Materials: Writing instruments ONE (8.5x11) formula sheet written on BOTH sides Disallowed Materials No electronic devices of ANY kind. No hats or containers such as purses, pencil cases, packsacks Notes: Questions are to be answered using C++ except where indicated as RobotC using You can assume for any programs that any necessary libraries (eg. #include <iostream> ) have been included. All questions will be marked for credit. If you need to make any assumptions to formulate your solution, state your assumptions clearly. Question Maximum Mark Mark 1. 12 2. 10 3. 10 4. 18 5. 25 6. 25 Total 100 University of Waterloo Final Examination Spring 2011 GenE 121 (C++/RobotC) Midterm Page 2 of 12 1. Short Answer [12 Marks Total] a. [3 Marks] Complete the statements below i. double a[2][2] declares an array of size _______4 or 2 by 2 _______. ii. 101010 in binary is ___42 ___ in base 10. iii. time1[2] measures elapsed time in ______milliseconds ___. b. [5 Marks] What is output by the following code? int main() { int black[5][5] = {{1,6,4,8,9}, {8,0,7,3,4}, {5,2,1,3,8}, {2,7,1,0,4}, {8,3,9,6,1}}; for(int i=0; i<5; i++) cout << black[i][i] << endl; return 0; } 1 0 1 0 1 c. [4 Marks] What is output by the following code? int mixer(int & a, int & b, int c) { c *= a; b = a--; return c; } int main() { int a = 9, b = -5, c = 2; cout << mixer(b,c,b) << endl << a << endl << b << endl << c << endl; return 0; } 25 9 -6 -5 Spring 2011 GenE 121 (C++/RobotC) Midterm Page 3 of 12 2. Functions [10 Marks Total] a. [5 Marks] Write a function that receives the base length of an equilateral triangle and returns the perimeter and area. void perimArea(double base, double &area, double &perim) { perim=3*base; double height=sqrt(.75*base*base); area=.5*base*height; } b. [5 Marks] Write a function that receives a 4 digit, integer ID number and prints the last two digits as the first two and the first two digits as the last two. For example 2983 would be 8329 and 3401 would be printed 0134....
View Full Document

{[ snackBarMessage ]}

### Page1 / 12

final_S11_soln - Term Spring Year 2011 Student Name UW...

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

View Full Document
Ask a homework question - tutors are online