9618/31/M/J/22 question 1: worked solution (May/June 2022, 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. Q3 9618/31/M/J/22 original Q1 Structured · 8 marks Worked solution (a) LibraryBook.Title ← "A Level Computer Science" LibraryBook.Fiction ← FALSE Title assigned using LibraryBook.Title and the text in quotes [1] Fiction assigned FALSE using LibraryBook.Fiction [1] (b)(i) Use a range type for the field. DECLARE NumberOfCopies : 1 .. 10 Range 1 .. 10 used in place of INTEGER [1] (b)(ii) One book can have many accession numbers, so use an array whose size is NumberOfCopies. DECLARE AccessionNumber : ARRAY[1:NumberOfCopies] OF INTEGER Array declared with the name AccessionNumber and bounds 1 to NumberOfCopies [1] Array elements are of type INTEGER [1] (c) A user-defined composite data type is: A data type made by the programmer , not a built-in (primitive) type [1] It refers to at least one other data type , and these can be primitive or user-defined [1] A correct example of another composite type, such as a class (object) or a set [1] KEY IDEA A composite type is built by the programmer from other types, such as a record, class or set. TOTAL 8 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.