1/8
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is meant by a user-defined data type? [2 marks]
1. A data type that is not built-in/primitive to the language [1]
2. Created and defined by the programmer to suit a specific problem [1].
State the difference between a non-composite (primitive user-defined) and a composite data type. [2 marks]
Non-composite: Does not involve a reference to any other data type (e.g., Enumerated, Pointer) [1].
Composite: Is constructed from/refers to multiple other data types (e.g., Record, Set, Class) [1].
Write pseudocode to declare an enumerated data type. [2 marks]
TYPE <TypeName> = (<Value1>, <Value2>, <Value3>, ...)
Example: TYPE DayOfWeek = (Monday, Tuesday, Wednesday, Thursday, Friday) [2]
Identify two characteristics/features of an enumerated data type. [2 marks]
1. The values are user-defined identifiers (constants) [1].
2. The data type is ordered/sequential (each value has an ordinal position/index) [1].
3. It is a non-composite data type [1].
Write pseudocode to declare a composite data type (Record/Class) containing multiple fields of different types, including a previously declared enumerated type. [4–5 marks]
TYPE <RecordName>
DECLARE <Field1> : <DataType1>
DECLARE <Field2> : <EnumTypeName>
DECLARE <Field3> : ARRAY[1..N] OF <DataType3>
ENDTYPE
Write pseudocode to declare a pointer data type. [2 marks]
TYPE <PointerTypeName> = ^<BaseTypeName>
Example: TYPE PtrNode = ^Node [2]
State advantages of using user-defined data types in programming. [2–3 marks]
1. Improves readability and maintainability of the code [1].
2. Allows logical grouping of related data items [1].
3. Provides built-in type safety/validation (especially enumerated types restrict variables to legal values only) [1].
Define a non-composite data type and give two examples.
A user-defined data type that does not involve a reference to another data type.
Examples: Enumerated, Pointer.
Define a composite data type and give three examples.
A user-defined data type that refers to / is constructed from one or more other data types.
Examples: Record, Set, Class/Object.