Cambridge AS Level Computer Science 9618 · 10.1 Data Types and Records

Q7 · 9618/22/M/J/24 Q3

Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 1 of 4.

Q79618/22/M/J/24original Q3Structured · 9 marks
Question 3 from 9618/22/M/J/24

Worked solution

(a)(i)

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
ENDTYPE

TYPE 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]

(a)(ii)

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]

(b)

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.

KEY IDEAAn array of records holds many items of mixed data under one name, and a loop can work through them all.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/22/M/J/24 question 3
VIDEO
▶ 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.