Write TYPE, DECLARE and DEFINE in 9618 pseudocode and see what your code makes: enumerated types, records, pointers and sets, and the memory that holds them.
9618/32 October/November 2022 · Question 4 · 10 marks
(a) Declare the enumerated data type Aircraft (C300, C350, D242, E757, X380). (b) Declare the composite data type Flight: flight number, destination, departure date and type of aircraft. (c)(i) Set up a variable for one record of type Flight. (ii) Store the details of flight XA782 to Cambridge on 12/12/2022 with aircraft C350.
Points that gain marks
(a) TYPE Aircraft = … (C300, C350, D242, E757, X380)
(b) TYPE Flight and ENDTYPE correct.
DECLARE FlightNumber and DECLARE Destination as STRING; DECLARE DepartureDate as DATE.
DECLARE AircraftType as Aircraft (the type from part (a)).
(c)(i) DECLARE Flight1 : Flight
(ii) Both STRING values, the DATE value and the enumerated value assigned correctly: Flight1.DepartureDate ← 12/12/2022, Flight1.AircraftType ← C350.
In this lab: Levels 3 and 4 build exactly this record.
9618/31 October/November 2021 · Question 3(a)(b) · 4 marks
(a) Write pseudocode to create an enumerated type called Parts: Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse. (b) Write pseudocode to create a pointer type called SelectParts that will reference the memory location in which the current part name is stored.
Points that gain marks
(a) TYPE Parts = (Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, Mouse)
(b) TYPE SelectParts = ^ …
… with the correct data type: Parts. TYPE SelectParts = ^Parts
In this lab: Levels 1 and 5.
9618/31 October/November 2023 · Question 3 · 4 marks
Describe what is meant by enumerated and pointer data types.
Points that gain marks
Enumerated: a user-defined non-composite data type …
… with a list of all possible values …
… that is ordered.
Pointer: a user-defined non-composite data type …
… that stores addresses (memory locations) only …
… and indicates the type of data stored in the memory location.
In this lab: The enumerated type shows its values in order; the pointer column in Memory holds an address.