{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

f2010fin - University of Waterloo Final Examination Term...

Info icon This 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
Image of page 1

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

View Full Document Right 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; }
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; }
Image of page 3

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

View Full Document Right 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.
Image of page 4
Initials: _______________________ ID Number: ___________________________ GENE 121 5 of 13 3. Structs [8 Marks Total] A C-style struct can be used to store complex numbers: struct Complex { double r, im; }; void scale(Complex & a, double b) { a.r *= b; a.im *= b; } a. How are the parameters a and b passed to the scale function?
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern