Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 1 of 4.
Write the record type with one DECLARE for each field. Use the type that suits each example value:
TYPE Component
DECLARE Item_Num : INTEGER
DECLARE Reject : BOOLEAN
DECLARE Stage : CHAR
DECLARE Limit_1 : REAL
DECLARE Limit_2 : REAL
ENDTYPETYPE and ENDTYPE statements [1]
Item_Num as INTEGER and Reject as BOOLEAN [1]
Stage as CHAR [1]
Limit_1 and Limit_2 as REAL [1]
Declare a 1D array with 2000 elements of the record type:
DECLARE Item : ARRAY[1:2000] OF Component
ARRAY with 2000 elements (for example [1:2000] or [0:1999]) [1]
Element type is Component [1]
Write any three of these:
Allows the program to use a loop to go through all the records [1]
A record can be reached directly using an index, for example Item[1].Stage [1]
The code is simpler and has less repeated code, so it is easier to write, understand, maintain, test or debug [1]
Other accepted point: the records are easier to search, sort or change.
▶ Starts at Q3 (23:43)
Starts at Q3 (23:43) · 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.