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