=========================preview======================
(COMP104)comp104-final2006.pdf
Back to COMP104 Login to download
======================================================
The Hong Kong University of Science and Technology
COMP104: Programming Fundamentals and Methodology
Fall 2006, Lecture Section 1, 2, 3

FINAL EXAMINATION
Tuesday, 8:30C11:30AM
December 19, 2006

Question 0: Complete your personal information below [ -1 mark if it is imcomplete].

Student Name: _____________________ Lecture Section: _________________________

Student ID: ________________________ Lab Section: ____________________________

Instructions:
1. This is a closed-book, closed-notes examination.

2. Check that you have all 18 pages (including this cover page and a blank page at the end).

3. Answer all questions using the space provided after each question.

4. Rough work should be done on the last blank page provided.

5. Unless otherwise stated, all programming language constructs described in the questions are C++s.



Question
Score

1
/ 10

2
/ 6

3
/ 7

4
/ 20

5
/ 17

6
/ 22

7
/ 18

Total
/ 100











Question 1: True or False [total 10 marks]

Indicate whether the following statements are true or false by circling the answer. You get 1 mark for each correct answer, but C1 mark for each wrong answer, and 0 mark if you do not answer. (Remark: statistically speaking, it is unwise to guess if you dont know the answer.)

[True/False] (a) In a 2-D array, if we want to find out the relative position of an array element, we must know how many rows there are in the array.

[True/False] (b) A variable has both lvalue and rvalue, but a pointer variable has only lvalue.

[True/False] (c) A const pointer is typically used to store address of another constant object.

[True/False] (d) The size of a pointer variable depends on the type of the object it points to.

[True/False] (e) If a formal parameter of a function is a pointer, then it is pass-by-reference.

[True/False] (f) Dynamic objects are unnamed.

[True/False] (g) Memory leak in a program often causes segmentation fault.

[True/False] (h) In order to prevent memory leak, the address of every dynamic object must be kept in a pointer variable.

[True/False] (i) When the main function returns, both static objects and dynamic objects are destroyed.



[True/False] (j) A variable with external linkage must be defined in each file before it can be used.



NOTICE
ALL questions in this exam paper are set under the assumption that the computing environment (both software and hardware) is the same as the current settings of CSE Lab2 machines as of the exam date.

Question 2 [total 6 marks]
Fill the blanks ______ below so that the program outputs the following lines:
Point A: 2,6
Point B: 4,8
Point A: 7,11
Point B: 9,13


#include <iostream>
u