9618/33/O/N/25 question 1: worked solution (October/November 2025, paper 33)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3. Q21 9618/33/O/N/25 original Q1 Structured · 8 marks Worked solution (a)(i) TYPE Spectrum = (Red, Orange, Yellow, Green, Blue, Indigo, Violet) TYPE Spectrum = [1] All seven colours in brackets, separated by commas [1] (a)(ii) Write any two of these: The list is ordered (each value has a position, so values can be compared) [1] The list holds all the possible values the type can take [1] Other points that score: there are no duplicate values, and all the values are of the same data type . (b) Start with TYPE and the name, DECLARE each field with the most suitable type, and end with ENDTYPE. TYPE ColourData DECLARE ColourCode : STRING DECLARE Colour : Spectrum DECLARE Wavelength : INTEGER DECLARE Frequency : REAL DECLARE PrimaryColour : BOOLEAN ENDTYPE TYPE ColourData and ENDTYPE [1] DECLARE used for every field [1] Colour declared with the type Spectrum [1] ColourCode as STRING, Wavelength as INTEGER, Frequency as REAL, PrimaryColour as BOOLEAN [1] KEY IDEA An enumerated type lists every allowed value in brackets, and a record type groups fields, each with the most suitable data type. TOTAL 8 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by ZAINEMATICS. Tap the picture to open it on YouTube.