Final_00

# Final_00 - Hong Kong University of Science and Technology...

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

Hong Kong University of Science and Technology COMP 102: Computer and Programming Fundamentals I Fall 2000 Final Examination 19 December 2000, 12:30-3:30pm Sports Hall Student Name: _________________________ Student Number: _________________________ Lecture & Lab Sections: _________________________ Instructions 1. This is a closed-book, closed-notes examination. 2. Check that you have all 19 pages (including this cover page). 3. Write your name, student number, lecture and lab sections on this page. 4. Answer all questions in the space provided. 5. Rough work should be done only on the back pages. 6. Please turn off your mobile phone/pager or else you will be disqualified. Question Maximum Points Your Points Question Maximum Points Your Points 1 4 7 6 2 4 8 7 3 5 9 7 4 6 10 14 5 15 11 10 6 4 12 18 YOUR TOTAL POINTS Lecture Section #1 (10:00-10:50am) Instructor : Renlan LIAO

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

View Full Document
2 1. (4 points total) Assume that the following declarations have been given: const int SIZE = 25; double A[SIZE]; a) What is the total number of elements in array A ? Answer: __________ b) What is the subscript of the first element of A ? Answer: __________ c) What is the subscript of the last element of A ? Answer: __________ d) Write a C++ statement that assigns the value 3 to the third element of A . Answer: ________________________________________
3 2. (4 points total) Consider the following array and function definitions: int array1[4] = {1, 2, 3, 4}; int array2[10]; void set4(int a[], int num) { for (int index = 0; index <= num; index++) a[index] = 4; } For each of the following function calls, mark it with “True” if it is correct and “False” if it is incorrect. You should consider both syntax and logical correctness. a) set4(array1, array1[2]); Answer: __________ b) set4(array1, 4); Answer: __________ c) set4(array2, 8); Answer: __________ d) set4(array2[4], 9); Answer: __________

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

View Full Document
4 3. (5 points) What is the output of the following program? #include <iostream.h> int code; void update_1(int& course_num) { course_num = course_num + 1; cout << course_num << endl; code = code + 1; cout << code << endl; } void update_2(int code) { code = code + 1; cout << code << endl; } int main() { code = 102; update_1(code); cout << code << endl; update_2(code); cout << code << endl; return 0; } Answer (just use as many lines as needed): ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________
5 4. (6 points total) Consider the following C++ program: #include <iostream.h> int main() {

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 09/30/2010 for the course COMP COMP102 taught by Professor Lrr during the Fall '09 term at HKUST.

### Page1 / 19

Final_00 - Hong Kong University of Science and Technology...

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

View Full Document
Ask a homework question - tutors are online