Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3.
Tick what each example uses:
| Pseudocode example | Selection | Iteration | Assignment |
|---|---|---|---|
| FOR Index ← 1 TO 3 ... NEXT Index | ✓ | ✓ | |
| OTHERWISE : OUTPUT "ERROR 1202" | ✓ | ||
| REPEAT UNTIL Index = 27 | ✓ | ||
| INPUT MyName | ✓ | ||
| IF Mark > 74 THEN Grade ← 'A' ENDIF | ✓ | ✓ |
FOR loop row: Iteration and Assignment [1]
OTHERWISE row: Selection [1]
REPEAT UNTIL row: Iteration [1]
INPUT row: Assignment [1]
IF row: Selection and Assignment [1]
Work out each expression:
| Expression | Evaluation |
|---|---|
| AAA AND (Count > 99) | FALSE |
| AAA AND (NOT BBB) | TRUE |
| (Count <= 99) AND (AAA OR BBB) | TRUE |
| (BBB AND Count > 50) OR NOT AAA | FALSE |
Any two rows correct [1]
All four rows correct [1]
Any one of these:
Use a Boolean as a flag to stop a loop when a value has been found [1]
Or: when a variable can only be one of two values, such as Yes or No, or a light being on or off.
▶ Whole paper
Video solution of the whole paper · by Digify ID. 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.