{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

S10Final - University of Waterloo Final Examination Term...

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

View Full Document Right Arrow Icon
Term: Spring Year: 2010 Student Name: ________________________________________ Student ID Number: ___________________________________ Course Abbreviation and Number GENE 121 (Mech Eng C++/RobotC) Course Title Digital Computation Section(s) 001 Instructor Rajnish Bassi Date of Exam August 7, 2010 Time Period Start time: 9:00 am End time: 11:30am Duration of Exam 2.5 hrs Number of Exam Pages 12 (including this cover sheet) Exam Type Special Materials Additional Materials Allowed ONE (8.5X11) formula sheet Writing instruments Notes: No electronic devices including NO CALCULATORS You can assume for any program that any necessary #include s have been written. If you need to make any assumption to formulate your solution, state your assumptions clearly. Answer all questions in the space provided. If you require additional space, write on the back of the opposite page and indicate this clearly. Unless specified in the question, you do not need to include error checking. Marking Scheme: Question Maximum Marks Mark 1 10 2 10 3 20 4 10 5 25 6 25 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
Page 2 of 12 1. Short Answer [10 marks] a) [4Marks] Answer true (T) or false (F) for each of the following ____ declaring arrays with more than two dimensions results in compile-time error ____ all C++ operators are evaluated from left to right ____ parameters passed by value to a function are considered as local variables ____ theoretically, ultrasonic sensor can detect obstacles within the range of 0-255 cm b) [3 Marks] What will be the output? int valRef (int &i, int j, int &k) { i = j * k; return ++j; } int valRef (int &i, int &j, double k) { i = j * k; return ++j; } int main() { int i, j = 2; double k = 2; i = valRef (j, j, k); cout << i << j; i = valRef (j, j, j); cout << i << j; return 0; }
Image of page 2
Page 3 of 12 c) [3 marks] What will be the output? int main() { int a[5] = {3, 5, 3, 6}, b = 2, c = 3; int *q = &b; *q = *(a+1)**q; c = (*a+1)**q; cout << b << " " << c ; return 0; } 2. Functions [10 marks] Write a function that receives an array of integers sorted in ascending order, the number of array elements, and another integer. The function must insert the integer into the correct position in the array. If the integer is already in the list, it should not be added again.
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
Image of page 4
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