Revision Notes
Cambridge A Level Computer Science (9618): Data Types and Records – Revision Notes
Condensed notes on choosing pseudocode data types and on defining, filling and reading records for Cambridge AS Computer Science 9618 10.1.
- Subject
- Computer Science
- Level
- AS LEVEL
- Topic
- Topic 10: Data Types and Structures
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to Cambridge A Level Computer Science (9618), 2026. Official specification .
Syllabus page (what it covers and how it is assessed): Cambridge A Level Computer Science.
Syllabus points this page covers
9618 (AS Level)
- 10.1 Data Types and Records
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9618).
Quick-recall notes for 10.1 Data Types and Records (AS content, mainly Paper 2). The Data Types and Records study guide has full worked examples; the Data Types and Records practice questions give exam-style practice. The rest of Topic 10 is summarised in the Data Types and Structures revision notes.
Pseudocode data types
| Type | Holds | Literal |
|---|---|---|
| INTEGER | Whole number | 25, -3 |
| REAL | Number with fractional part | 4.75, 0.0 |
| CHAR | One character | 'K' |
| STRING | Any number of characters, including none | "Kiran", "" |
| BOOLEAN | TRUE / FALSE | TRUE |
| DATE | Calendar date | dd/mm/yyyy |
The syllabus also lists ARRAY (10.2) and FILE (10.3) as pseudocode types.
Choosing a type: decision list
- No arithmetic, or leading zeros matter → STRING (phone numbers, IDs, postcodes).
- Fractional part possible → REAL (money, mass, averages).
- Whole numbers only → INTEGER (counts, years, scores).
- Exactly two states → BOOLEAN (paid, present).
- Exactly one character → CHAR (grade, code letter).
- A date to compare or sort → DATE.
Common type choices
| Data | Type | Not… | Because |
|---|---|---|---|
| Telephone number | STRING | INTEGER | Leading zero lost; no arithmetic |
| Price | REAL | INTEGER | Has pence/cents |
| Number of tickets | INTEGER | REAL | Cannot be fractional |
| Member? | BOOLEAN | STRING | Only two states; avoids “Y”/“yes” mismatches |
| Shirt size S/M/L | CHAR | STRING | One character only |
| Date of birth | DATE | STRING | Dates as strings do not sort correctly |
| Product code “A17” | STRING | CHAR | More than one character |
| Distance run in km | REAL | INTEGER | 5.4 km must keep its decimal part |
| Year of manufacture | INTEGER | STRING | Used in arithmetic, e.g. age of a car |
Records: the essentials
- Purpose: hold related data of different types under one identifier.
- Field: one item in the record.
- Dot notation:
Variable.Field. - An array of records stores a table: one element per row.
TYPE TBook
DECLARE ISBN : STRING
DECLARE Title : STRING
DECLARE Pages : INTEGER
DECLARE Price : REAL
DECLARE OnLoan : BOOLEAN
ENDTYPE
DECLARE ThisBook : TBook
DECLARE Library : ARRAY[1:2000] OF TBook
Save data to a record
INPUT ThisBook.Title
ThisBook.OnLoan ← FALSE
Library[12].Title ← "Tide Tables"
Library[12].OnLoan ← TRUE
Read data from a record
OUTPUT Library[12].Title
IF Library[12].OnLoan = TRUE THEN
OUTPUT "On loan"
ENDIF
Filling an array of records from input
DECLARE Index : INTEGER
FOR Index ← 1 TO 3
OUTPUT "Book ", Index
INPUT Library[Index].ISBN
INPUT Library[Index].Title
INPUT Library[Index].Pages
INPUT Library[Index].Price
Library[Index].OnLoan ← FALSE
NEXT Index
Reading back with a condition: count the books over 300 pages.
Count ← 0
FOR Index ← 1 TO 3
IF Library[Index].Pages > 300 THEN
Count ← Count + 1
ENDIF
NEXT Index
OUTPUT Count
The loop variable picks the record; the field name after the dot picks the item inside it. Fields that are not input (OnLoan here) still need a starting value.
Why records rather than separate arrays
| Separate (parallel) arrays | Array of records |
|---|---|
| One array per field, kept in step by index | One array; each element holds all fields |
| Easy to sort one array and forget the others | Whole record moves together |
| Many identifiers to pass to a subroutine | One identifier passed |
Key terms
| Term | Meaning |
|---|---|
| Data type | Defines the values a variable can hold and the operations allowed |
| Record | Composite structure grouping fields of different types under one identifier |
| Field | One named item within a record |
| Record type | User-defined type created with TYPE … ENDTYPE |
| Dot notation | Accessing a field as Variable.Field |
| Composite type | Type built from other types, such as a record or array |
Exam traps
- CHAR in single quotes, STRING in double quotes.
- TYPE defines the structure; you still need
DECLARE Var : TypeName. - The dot follows the variable (
ThisBook.Title), never the type (TBook.Title). - With arrays of records, the index comes before the dot:
Library[12].Title. - Every field in TYPE needs its own DECLARE with a type.
- “It is a number” is not enough to choose INTEGER; ask whether arithmetic is done on it.
Self-test
- Give the data type for a mean exam mark.
- Why should a bank account number with leading zeros be a STRING?
- Which type would you use for whether a seat is booked?
- Write a valid CHAR literal and a valid STRING literal.
- State the purpose of a record structure.
- What is a field?
- Write the TYPE definition for TPet with Name (STRING), Species (STRING), Age (INTEGER) and Vaccinated (BOOLEAN).
- Declare a variable MyPet of type TPet.
- Write a statement that sets MyPet’s age to 4.
- Pets is an ARRAY[1:50] OF TPet. Write a statement that outputs the name of the 7th pet.
- Give one advantage of an array of records over parallel arrays.
- Why is DATE better than STRING for a due date?
Answers
- REAL.
- INTEGER would drop the leading zeros, and no arithmetic is done on it.
- BOOLEAN.
'Q'and"Queue".- To hold a set of related data of different data types under one identifier.
- One named data item within a record.
TYPE TPet/DECLARE Name : STRING/DECLARE Species : STRING/DECLARE Age : INTEGER/DECLARE Vaccinated : BOOLEAN/ENDTYPEDECLARE MyPet : TPetMyPet.Age ← 4OUTPUT Pets[7].Name- Any one: all fields of a record stay together (e.g. when sorting); only one identifier to manage or pass to a subroutine.
- Dates can be compared and sorted correctly; as strings, “02/03/2026” would sort before “15/01/2026”.
Related resources
-
Study guides
Cambridge A Level Computer Science (9618): Files
Why programs need files, and pseudocode for reading, writing, appending and searching text files, for Cambridge AS Computer Science 9618 section 10.3.
Computer Science · Cambridge · AS Level
Read guide -
Practice questions
Cambridge A Level Computer Science (9618): Files – Practice Questions
Original questions with mark-scheme answers on reading, writing, appending and searching text files in pseudocode for Cambridge AS Computer Science 9618.
Computer Science · Cambridge · AS Level
Try questions -
Revision notes
Cambridge A Level Computer Science (9618): Files – Revision Notes
Condensed notes on why files are needed and on file modes, READFILE, WRITEFILE and EOF patterns for Cambridge AS Computer Science 9618 10.3.
Computer Science · Cambridge · AS Level
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.