midw2011_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: Winter Year: 2011 Student Name: ______________________________________________________________________ UW Student ID Number: ______________________________________________________________ Signature: __________________________________________________________________________ Course Abbreviation and Number GEN E 121 (ME C++/RobotC) Course Title Digital Computation Section(s) 001 Instructor C. Hulls Date of Exam Friday, February 18, 2011 Time Period Start time: 8:30am End time: 10:30am 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. If you need extra space to answer a question, use the back of the previous page. Question Maximum Mark Mark 1. 16 2. 10 3. 12 4. 12 5. 20 6. 20 Total 90 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
GenE 121 (C++/RobotC) Midterm Page 2 of 8 1. Short Answer [16 Marks Total] a. [10 Marks] Write one line of code to: i. Declare an array of double s of size 5 double varName[5]; ii. Set the power for motorA to be 25%. Motor[motorA]=25; iii. Declare a Boolean variable isEven that is initialized based on whether n is even or not bool isEven=(n%2==0); iv. Output the maximum of 3 integers, a , b , c using the max function cout<<max(a,max(b,c)); v. Configure the ultrasonic sensor as sensor S3. sensorType[S3]=sensorSONAR; b. [3 Marks] Write the value of the following expressions. i. 2 + 5 * 3 / 2 + 6 % 10 1 = 14 ii. 9 > 7 >= 2.1 = 0 iii. pow(8, 1/3) = 1 c. [3 Marks] motorA is connected to the left motor, and motorC is connected to the right motor. Describe the robot motion for the following code: motor[motorA] = 80; motor[motorC] = 20; wait10Msec(300); motor[motorA] = 20; wait10Msec(400); motor[motorC] = -20; wait10Msec(250); The robot will move in an arc, turning to the right for 3 seconds. The robot will then move
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

midw2011_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