S11_mid_soln - University of Waterloo Midterm Examination...

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

View Full Document Right Arrow Icon
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 Friday, June 17, 2010 Time Period Start time: 2:00pm End time: 4:00pm Duration of Exam 2 hours Allowed Materials: Writing instruments ONE (8.5x11) formula sheet written on ONE side only 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. 28 2. 15 3. 10 4. 15 5. 15 6. 25 Total 108 University of Waterloo Midterm 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
Spring 2011 GenE 121 (C++/RobotC) Midterm Page 2 of 8 1. Short Answer [28 Marks Total] a. [10 Marks] Write one line of code to i. Display the variable double a=3.14159 on the console with two decimal places. Cout<<fixed<<setprecision(2)<<a<<endl; ii. Set the power for motorC to be 95%. Motor[motorC]=95; iii. Compute the maximum of integers a , b , c using the max function; store the result in int m . Int m=max(a,max(b,c)); iv. Declare an array of one-hundred float s. Float arr[100]; v. Configure the touch sensor sensorTouch as sensor S2 . sensorType[S2]=sensorTouch; b. [3 Marks] Write the value of the following expressions. i. 4 * 5 / 3 + 3 % 5 4 5 ii. 12 > 10 > 7 0 iii. pow(4.0, 1/2) 1 c. [5 Marks] What is output by the following code? int n = 5; int m = 1; m+=n; cout << m << endl; 6 if(n) 5 cout << n << endl; 5 else if(n==5) 6 cout << n+10 << endl; m = n++; cout << m << endl; cout << n << endl; d. [10 Marks] The ultrasonic sensor is connected to port S1 , left motor to motorA and right motor to motorB . The robot is facing a wall that is 200 cm away, the ultrasonic sensor is mounted on the front of the robot and also facing the wall. Someone observes that the robot is powered on and
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 04/01/2012 for the course GENE 121 taught by Professor Smucker during the Winter '11 term at Waterloo.

Page1 / 8

S11_mid_soln - University of Waterloo Midterm Examination...

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