Upgrade to access all Cambridge 9618 lessons including records, file handling, and data structures.
Upgrade to Pro →A record is a composite data type that groups together related fields of different data types under one name. This is equivalent to a struct in C or a class with only fields.
Records are ideal when you want to store multiple pieces of information about a single entity — such as a student (name, age, score) or a product (code, name, price, quantity).
In Cambridge 9618, a record type is declared using TYPE...ENDTYPE:
Once the type is defined, you declare variables of that type and access fields using dot notation:
Combining arrays and records is very powerful — you can store multiple records in an array:
File handling allows programs to read and write data that persists after the program ends. Cambridge 9618 uses four file operations:
| Feature | Array | Record |
|---|---|---|
| Data types of elements | All must be the same type | Different fields can have different types |
| Access method | By integer index: A[3] | By field name: s.name |
| Typical use | Multiple values of same type (list of marks) | Multiple properties of one entity (a student record) |
| Cambridge keyword | DECLARE x : ARRAY[1:n] OF type | TYPE name ... ENDTYPE |
| Can they be combined? | Yes — ARRAY[1:n] OF RecordType is valid and common | |
. notation before declaring the record variable (DECLARE s1 : Student must come first)CLOSEFILE — this loses marks in Cambridge papersEOF — causes a runtime error when reading past the end:= instead of ← when assigning record fields8 questions · Cambridge 9618 standard
Product with fields: code (STRING), name (STRING), price (REAL), and inStock (BOOLEAN).[4]pupil of type Student and assign appropriate values to each field.[5]CLOSEFILE is important and what could happen if it is omitted.[2]| Term | Definition |
|---|
10 questions · 10 marks · 10 minutes