COS1511 Oct/Nov 2016 exam paper — questions

🔒 Scan locked

The paper, as written

Every question, by topic

  1. Question 1.1 · Code tracing and variable diagrams · 1 mark

    Given the code fragment: int x = 10; x += x; x += x+5; — determine the value of x after this code has been executed.Show the full question
  2. Question 1.2 · Code tracing and variable diagrams · 1 mark

    Given the following for loop: j = 0; for(int i = 5; j < 10; i++) { j += i; cout << i << '\t' << j << endl; } — state how many times the loop will iterate.Show the full question
  3. Question 1.3 · Code tracing and variable diagrams · 1 mark

    Consider this C++ program: it includes <iostream>, uses namespace std, declares a global int num = 0, defines a function void set_num() that declares a local int num = 6, and a main() function that calls set_num() and then outputs num using cout. State what the output of this program is.Show the full question
  4. Question 1.4 · Code tracing and variable diagrams · 1 mark

    Given the code segment: int a = 5; a++; cout << a++; — state what the output is.Show the full question
  5. Question 1.5 · Code tracing and variable diagrams · 1 mark

    An array variable arr is declared and initialised as follows: int arr[][2] = {{3,2},{4,5},{9,7}}; — state the value stored at array position arr[2][1].Show the full question

The full Spot Map and the marks by year — and this paper’s scan.