Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
The loop is WHILE … ENDWHILE, so the test is at the start.
Type: pre-condition loop (a WHILE loop) [1]
Condition: the loop ends when the input value (ThisNum) is equal to zero [1]
Run each input through the loop. Only write the values that change.
| ThisNum | ThisChar | CountA | CountB | Flag | OUTPUT |
|---|---|---|---|---|---|
| 0 | 10 | TRUE | |||
| 12 | '1' | 1 | |||
| 24 | '2' | ||||
| 57 | '5' | "Ignored" | |||
| 43 | '4' | 9 | FALSE | ||
| 56 | '5' | 4 | |||
| 22 | '2' | TRUE | "Flip" | ||
| 31 | '3' | 8 | |||
| 32 | '3' | 7 | |||
| 47 | '4' | 6 | FALSE | ||
| 99 | '9' | TRUE | "Flip" | ||
| 0 | 4 |
Columns ThisNum and ThisChar correct [1]
Rows for 12, 24 and 57 correct (CountA 1, then "Ignored") [1]
Rows for 43 and 56 correct (CountB 9, Flag FALSE, CountA 4) [1]
Rows for 22 and 31 correct (Flag TRUE, "Flip", CountB 8) [1]
Rows for 32 and 47 correct (CountB 7, then 6, Flag FALSE) [1]
Rows for 99 and 0 correct (Flag TRUE, "Flip", final OUTPUT 4) [1]
Integration testing means:
Modules that have already been tested individually [1]
are combined into one (sub) program which is then tested as a whole [1]
▶ Whole paper
Video solution of the whole paper · by Awab Aqib. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.