Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Run the loop for each number. Lowest starts at 900 and Highest at 1.
| Count | Number | Lowest | Highest |
|---|---|---|---|
| 900 | 1 | ||
| 1 | 563 | 563 | 1 |
| 2 | 21 | 21 | 1 |
| 3 | 376 | 21 | 376 |
| 4 | 99 | 21 | 376 |
| 5 | 400 | 21 | 400 |
Count column correct [1]
Number column correct [1]
Lowest column correct [1]
Highest column correct [1]
Reason: the ELSE means Highest is only checked when the number is not a new lowest, so Highest is wrong (the first number, 563, becomes the Lowest and Highest stays 1). [1]
Correction: replace ELSE on line 08 with ENDIF and remove the ENDIF on line 13, so there are two separate IF statements, one for Lowest and one for Highest. [1]
▶ Topic lesson
A lesson on this topic · by Mr Bulmer's Learning Zone. 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.