[Univ of Cambridge] [Dept of Engineering]

C++LentWelcome

Cipolla Welcome back! Hope you enjoyed your break. This term you'll be learning more C++, but first here's a quiz so that you can see if you've forgotten anything over the holiday. Look at the following code (the line numbers aren't part of the code)
#include <iostream.h>      [0]
int num[5];                [1]
                           [2]
int triple(int num) {      [3]
  return num*3;            [4]
}                          [5]
                           [6]
int main() {               [7]
int i=4;                   [8]
cout <<triple(i)  << endl; [9]
return 0;                 [10]
}                         [11]
  1. What is num on line 1?
    an integer
    an array
    a function
  2. What is triple?
    an integer
    an array
    a function
  3. How many comments are in this code?
  4. When this is compiled and run, what is printed out?

[1A C++] [Help]

Updated December 2000
tpl@eng.cam.ac.uk