Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3.
| Question | Answer |
|---|---|
| Line with a variable being incremented | 19 |
| Type of loop structure | pre-condition |
| Number of functions used | 3 |
| Parameters passed to STR_TO_NUM() | 1 |
| Procedure other than Check() | Result |
Line 19 (21 or 23 also accepted) [1]
Pre-condition loop (WHILE) [1]
3 functions: LENGTH, MID and STR_TO_NUM [1]
1 parameter [1]
Result [1]
Write three of these features:
Meaningful variable names [1]
Indentation / white space / blank lines [1]
Capital letters for keywords [1]
Write: a count-controlled loop (FOR ... NEXT) [1]
Justification: the number of repeats is known, as it is the length of InString [1]
The FOR loop sets and adds to Index itself, so the Index ← 1 line and the Index ← Index + 1 line are not needed.
Write 15 and 23 [1]
▶ Whole paper
Video solution of the whole paper · by CS BY AQIB KHAN. 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.