Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3.
Fill each gap so the code does what the bullet points say.
Line 01: 50 (the array has 50 elements, so the loop must reach 50) [1]
Line 08: Value > 50 (the valid range is 35 to 50, so reject anything above 50) [1]
Line 12: Reading[Value] + 1 (add 1 to the count for this value) [1]
Line 18: INPUT Value (read the next reading inside the loop) [1]
Line 23: Reading[Count] (output how many times this value was input) [1]
Line 24: Count + 1 (move on to the next value) [1]
Count down from the highest value instead of up from the lowest. Change these places:
Line 21: set Count to 50 instead of 35 [1]
Line 24: subtract 1 from Count (Count ← Count - 1) [1]
Line 25: change the end test to UNTIL Count < 35 (or Count = 34) [1]
A FOR loop from 50 TO 35 STEP -1 (with lines 22 and 24 removed) also scores.
▶ Topic lesson
A lesson on this topic · by Craig'n'Dave. 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.