=========================preview======================
(COMP102)Midterm 2000 Fall.pdf
Back to COMP102 Login to download
======================================================

Hong Kong University of Science and Technology
COMP 102: Computer and Programming Fundamentals I
Fall 2000
Midterm Examination


23 October 2000, 7:00-8:30pm
Lecture Theatre A-D




Student Name: _________________________

Student Number: _________________________

Lecture & Lab Sections: _________________________






Instructions

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


2.
Check that you have all 11 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 using a ball pen.


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
5

7
6


2
10

8
12


3
8

9
12


4
4

10
15


5
6

11
14


6
8



YOUR TOTAL POINTS





Version 1


1.
(5 points)




Which of the following are legal identifier names in C++? Mark the correct answers with Y and incorrect answers with N in the space provided.


a)
AT&T ____________




b)
Good-luck ____________




c)
Ms_Word ____________




d)
7pm ____________




e)
WHILE ____________










2.
(10 points)


int a = 2, b = 3, c = 4;
double d = 5.1, e = 5.0, s = 15.3, t = 27.3;
int x = 16, y = 10, z = 27;

What is the value of each of the following expressions? (Each expression should be evaluated with the same set of initial values as given above.)



a)
e / y ____________________________





b)
a * b / c + d ____________________________




c)
t / b + a / b * z ____________________________




d)
z / b * a / b * b ____________________________




e)
z % b * a / b * z ____________________________




f)
(int)(s / e) ____________________________




g)
y / (double)b ____________________________




h)
a * (b + 1) % c _______________________________




i)
x++ + y _______________________________




j)
x-- + y % ++b _______________________________




3.
(8 points)




The following C++ program contains some syntax errors. For each erroneous line, rewrite the corrected line in the space provided. A single line may contain zero or more errors.

#include (iostream.h) _____________________________________

int Main ( ) ; _____________________________________

{ _____________________________________

integer a; _____________________________________

cout << 'a = ' << a; _____________________________________

cout endl; _______________________________