Cambridge O Level Computer Science 2210 · 8.2 Arrays

Q43 · 2210/22/M/J/21 Q5

Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3.

Q432210/22/M/J/21original Q5Structured · 4 marks
Question 5 from 2210/22/M/J/21

Worked solution

(a)

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 Count

A FOR loop used [1]

Loop runs the correct number of times (1 to 20) [1]

Each element dataArray[Count] assigned 0 [1]

(b)

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]

KEY IDEAWhen you know how many times to repeat, use a FOR loop.
TOTAL 4 marks

Official mark scheme

Mark scheme for 2210/22/M/J/21 question 5
VIDEO
▶ 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.