Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types

Q7 · 9618/31/M/J/23 Q4

Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3.

Q79618/31/M/J/23original Q4Structured · 4 marks
Question 4 from 9618/31/M/J/23

Worked solution

(a)

An enumerated type lists every allowed value in brackets, after TYPE and a name.

TYPE Prime = (2, 3, 5, 7, 11, 13, 17, 19)

TYPE with a sensible name for the new type, followed by = [1]

All eight prime numbers listed in brackets, separated by commas [1]

(b)

A pointer type uses ^ followed by the type of data it points to. The days are words, so point to a STRING.

TYPE TDayPointer = ^STRING

TYPE with a sensible name for the pointer type, followed by = [1]

^ followed by a data type (^STRING or ^DayOfWeek) [1]

KEY IDEAEnumerated types list their values in brackets, and pointer types use ^ followed by the type of data they point to.
TOTAL 4 marks

Official mark scheme

Mark scheme for 9618/31/M/J/23 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by qiphyedu. 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.