Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3.
Decide which constructs each example uses:
| Pseudocode example | Selection | Iteration | Subroutine |
|---|---|---|---|
| FOR ... IF ... NEXT | ✓ | ✓ | |
| CASE OF Compound(3) | ✓ | ✓ | |
| REPEAT UNTIL AllDone() = TRUE | ✓ | ✓ | |
| WHILE Result[3] <> FALSE | ✓ |
FOR loop with IF row correct (selection and iteration) [1]
CASE row correct (selection and subroutine, because Compound(3) is a function call) [1]
REPEAT row correct (iteration and subroutine, because AllDone() is a function call) [1]
WHILE row correct (iteration only) [1]
Look at the example value:
| Variable | Example data value | Data type |
|---|---|---|
| Available | TRUE | BOOLEAN |
| Received | "18/04/2021" | STRING |
| Index | 100 | INTEGER |
Available is BOOLEAN [1]
Received is STRING (it is in quote marks) [1]
Index is INTEGER [1]
Use Available = TRUE and Index = 100:
| Expression | Evaluates to |
|---|---|
| Available AND NOT(Index > 100) | TRUE |
| Index MOD 30 | 10 |
| NUM_TO_STR(Index + "33") | ERROR |
Index > 100 is FALSE, NOT makes it TRUE, TRUE AND TRUE gives TRUE [1]
100 ÷ 30 = 3 remainder 10, so 10 [1]
Index + "33" adds a number to a string, which is not allowed, so ERROR [1]
▶ Whole paper
Video solution of the whole paper · by Zafar Ali Khan (ZAK). 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.