Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.
Look for each type of statement in the numbered lines.
Assignment statement: line 01 (or 02, 08 or 12) [1]
Loop: line 03 and/or line 14 (REPEAT … UNTIL) [1]
Counting statement: line 08 or 12 [1]
Selection statement: line 06 (or 10, 15 or 19) [1]
Read what each part of the algorithm should do.
Line 02: TooCold starts at 1000. Change to TooCold ← 0 [1]
Line 08: the count goes down. Change to TooCold ← TooCold + 1 [1]
Line 15: it should be more than 5. Change to IF TooHot > 5 [1]
Line 17: INPUT is used to show a message. Change to OUTPUT "Alarm!!" [1]
Count the readings that are inside the range with a new counter. Any four of these:
Add a new variable, for example InRange [1]
Set it to 0 at the start of the algorithm [1]
Add an extra IF statement with the test Temperature >= -25 AND Temperature <= -18 [1]
If it is true, add 1 to InRange [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.