9618/32/M/J/24 question 3: worked solution (May/June 2024, paper 32)

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. Q12 9618/32/M/J/24 original Q3 Structured · 7 marks Worked solution (a) A non-composite data type is defined without referring to another data type. [1] It can be a primitive data type or a user-defined data type. [1] Example: an enumerated type, for example TYPE Season = (Spring, Summer, Autumn, Winter), or a pointer type. [1] (b) A set type is declared with TYPE, then a variable of that type is given its values with DEFINE. TYPE Numbers = SET OF INTEGER DEFINE EvenNumbers (2, 4, 6, 8, 10, 12) : Numbers TYPE statement fully correct (TYPE Numbers = SET OF INTEGER) [1] DEFINE EvenNumbers [1] Correct list of values in brackets [1] Type name written after the colon [1] Any sensible name for the type is accepted, as long as it is used after the colon. KEY IDEA A set type uses TYPE ... = SET OF, then DEFINE gives the variable its values and its type. TOTAL 7 marks Official mark scheme VIDEO ▶ Starts at Q3 (18:09) Starts at Q3 (18:09) · by Pseudocode Pro. Tap the picture to open it on YouTube.