2210/22/M/J/21 question 5: worked solution (May/June 2021, paper 22)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 8.2 Arrays Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3. Q43 2210/22/M/J/21 original Q5 Structured · 4 marks 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 IDEA When you know how many times to repeat, use a FOR loop. TOTAL 4 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by CS BY AQIB KHAN. Tap the picture to open it on YouTube.