Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.
Step through Array1 three values at a time. Add the three values, divide by 3, make it an INTEGER and store it in the next place in Array2.
PROCEDURE Summarise()
DECLARE Value : REAL
DECLARE IxA, IxB : INTEGER
IxB ← 1
FOR IxA ← 1 TO 598 STEP 3
Value ← Array1[IxA] + Array1[IxA + 1] + Array1[IxA + 2]
Value ← Value / 3
Array2[IxB] ← INT(Value)
IxB ← IxB + 1
NEXT IxA
ENDPROCEDUREProcedure heading and ending, with both index variables declared [1]
Loop that goes through every element of Array1 (for example STEP 3) [1]
Adds three consecutive values from Array1 and divides by 3, inside the loop [1]
Result converted to an integer (for example INT) [1]
Result assigned to the correct element of Array2, and the Array2 index increased, inside the loop [1]
▶ Whole paper
Video solution of the whole paper · by Pseudocode Pro. 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.