Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3.
The array has a fixed size of 20, so use a FOR loop with a counter that goes from 1 to 20.
FOR Count ← 1 TO 20
dataArray[Count] ← 0
NEXT CountA FOR loop used [1]
Loop runs the correct number of times (1 to 20) [1]
Each element dataArray[Count] assigned 0 [1]
Write: a FOR loop has a fixed number of repetitions, and the loop counter is managed for you, so no extra variable is needed for the array index. [1]
▶ Whole paper
Video solution of the whole paper · by CS BY AQIB KHAN. 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.