Quelpr

CAPE Computer Science Unit 1 · 2014 · Paper 2 · Question 6(c)

Given the following C program: #include <stdio.h> int main () { int i, j, final = 1; for (j = 9; j > 0; j = j - 3) { i = j / 3; while (i < j) { printf("\ni is %d j is %d\n",i, j); j--; i = i + 1; final = final + 2*j; } //while printf("\nNew i = %d", i); }//for printf("\nFinal Output: %d\n", final); scanf("%c"); return 0; }//main

What output is produced by the following C program? (For the output state the values of i and j at each stage.)

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 6(a)Explain why indentation is important in programming.[2 marks]
  2. 6(b)Why is it recommended that comments be used in programming code?[2 marks]
  3. 6(d)Write a C program that accepts two values, price and tax (both of type float). The program applies tax to price and prints the old price and the new price in…[6 marks]
  4. 6(e)Write C code to read four integers and print their average. (Do not write an entire program.)[4 marks]

More practice: the rest of this paper · more Algorithm Verification and Development questions · all CAPE Computer Science Unit 1 past papers