F2010fin - University of Waterloo Final Examination Term Fall Year 2010 Student Name(Print Signature UW Student ID Number Course Abbreviation and

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

View Full Document Right Arrow Icon
Term: Fall Year: 2010 Student Name (Print) ____________________________________________________________ Signature ______________________________________________________________________ UW Student ID Number _______________________________________________________ Course Abbreviation and Number GENE 121 Course Title Digital Computation Section(s) 001 Instructor C. Hulls Date of Exam Saturday December 11, 2010 Time Period Start time: 9:00 am End time: 11:30 am. Duration of Exam 2.5 hours Number of Exam Pages 13 (including this cover sheet) Exam Type Special Materials Additional Materials Allowed ONE 8.5x11 sheet marked on BOTH sides Notes: No electronic devices of ANY kind. No hats or containers such a purses, pencil cases, packsacks You can assume for any programs that any necessary libraries (e.g. #include <iostream> ) have been included. Answer all questions in the space provided. If you require additional space, write on the back of the opposite page and indicate this clearly. If you need to make any assumptions to formulate your solution, state your assumptions clearly. Marking Scheme: Question Maximum Mark Mark 1. 14 2. 7 3. 8 4. 10 5. 18 6. 22 7. 7 8. 14 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
Initials: _______________________ ID Number: ___________________________ GENE 121 2 of 13 1. Short Answer [14 Marks Total] a. [2 Marks]What is the difference between analog and digital? b. [3 Marks] Can a binary search be used on an unsorted list? Explain why or why not by briefly describing, in one or two sentences, how a binary search works. c. [2 Marks] Code to wait for a button push using the Arduino can be written as: while (digitalRead(BUTTON) == LOW); delay(200); How long is the delay in seconds? Why is it included? d. [2 Marks] What is output by the following code? int main() { string greeting = "Hapoy"; greeting[greeting.size() - 1] = 'p'; string year = "2010"; year = year + '1'; cout << greeting << " " << year << endl; return 0; }
Background image of page 2
Initials: _______________________ ID Number: ___________________________ GENE 121 3 of 13 e. [5 Marks] What is output by the following code? void mix(int* x, int* y, int* z) { if (*x > *y) { int* p = x; x = y; y = p; } if (*x > *z) { int q = *x; *x = *z; *z = q; } *x *= -1; *z *= -1; } int main() { int a = 9, b = 7, c = 2; mix(&a, &b, &c); cout << a << " " << b << " " << c << endl; return 0; }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Initials: _______________________ ID Number: ___________________________ GENE 121 4 of 13 2. Arrays [7 Marks Total] Write a function that receives an array of integers and the number of integers, and returns the smallest even and odd integers.
Background image of page 4
Initials: _______________________ ID Number: ___________________________ GENE 121 5 of 13 3. Structs
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
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 / 13

F2010fin - University of Waterloo Final Examination Term Fall Year 2010 Student Name(Print Signature UW Student ID Number Course Abbreviation and

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online