9618/31/M/J/23 question 4: worked solution (May/June 2023, paper 31)

Show as 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. Q7 9618/31/M/J/23 original Q4 Structured · 4 marks 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 IDEA Enumerated 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 VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.