Students will be able to select the most appropriate primitive or derived data type for a given problem, define a record in Cambridge‑style pseudocode, and produce a complete identifier table. The content also covers the required array and file concepts and introduces the basic abstract data types (ADTs) that appear later in the syllabus.
| Type | Typical Size (bits) | Range / Values | Typical Use |
|---|---|---|---|
| INTEGER | 32 | ‑231 to 231‑1 | Whole numbers, counters, indexes |
| REAL | 32 (single) or 64 (double) | ≈ ±3.4 × 1038 (≈7 dp) or ±1.8 × 10308 (≈15 dp) | Measurements, scientific calculations, monetary values (when fixed‑point is not required) |
| CHAR | 8 | ASCII characters 0…127 | Single characters, codes |
| STRING | Variable (1 byte per character) | Sequence of CHAR values; length fixed in the declaration | Names, messages, textual data |
| BOOLEAN | 1 (conceptually) | TRUE / FALSE | Logical conditions, flags |
| DATE | Variable (often three INTEGER fields) | Valid calendar dates, e.g. 2025‑12‑30 | Birth dates, timestamps, scheduling |
OPEN, READ, WRITE, CLOSE.| AO | What is assessed | How the notes address it |
|---|---|---|
| AO1 | Recall terminology and definitions | Lists of primitive/derived types, syntax for RECORD, ARRAY and FILE |
| AO2 | Select appropriate data types and justify choices | Decision checklist, examples with justification, AO‑mapping table |
| AO3 | Design and use records, arrays and files in a program | Full record definitions, identifier tables, array declaration, file‑handling snippets, bubble‑sort/linear‑search examples |
record Student
INTEGER studentID
STRING firstName[30]
STRING lastName[30]
DATE dateOfBirth
REAL gpa
BOOLEAN isFullTime
endrecord
| Identifier | Type | Description |
|---|---|---|
| studentID | INTEGER | Unique numeric identifier for the student |
| firstName | STRING[30] | Given name (max 30 characters) |
| lastName | STRING[30] | Family name (max 30 characters) |
| dateOfBirth | DATE | Birth date in the format YYYY‑MM‑DD |
| gpa | REAL | Grade Point Average (0.0 – 4.0) |
| isFullTime | BOOLEAN | TRUE if the student is enrolled full‑time |
DECLARE stud : Student
stud.studentID ← 10234
stud.firstName ← "Emma"
stud.gpa ← 3.75
IF stud.isFullTime THEN
// process full‑time student
ENDIF
record Book
STRING ISBN[13] // keep leading zeros
STRING title[100]
STRING author[50]
INTEGER publishedYear
REAL price
BOOLEAN isAvailable
endrecord
Book| Identifier | Type | Description |
|---|---|---|
| ISBN | STRING[13] | 13‑digit International Standard Book Number |
| title | STRING[100] | Title of the book |
| author | STRING[50] | Author’s name |
| publishedYear | INTEGER | Year the book was published |
| price | REAL | Retail price (e.g. £12.99) |
| isAvailable | BOOLEAN | TRUE if the book is on the shelf |
DECLARE library : ARRAY[1..1000] OF Book // up to 1000 books DECLARE numberOfBooks : INTEGER ← 0
| Identifier | Type | Description |
|---|---|---|
| library | ARRAY[1..1000] OF Book | Stores the collection of books in the library |
| numberOfBooks | INTEGER | Current count of valid entries in library |
OPEN "library.dat" FOR WRITE AS bookFile
FOR i ← 1 TO numberOfBooks DO
WRITE bookFile FROM library[i]
ENDFOR
CLOSE bookFile
OPEN "library.dat" FOR READ AS bookFile
i ← 1
WHILE NOT EOF(bookFile) DO
READ bookFile INTO library[i]
i ← i + 1
ENDWHILE
numberOfBooks ← i - 1
CLOSE bookFile
INTEGER or REAL.INTEGER range? → Use a larger type (e.g., LONG) or split the data.CHAR for a single character, STRING[n] for longer text.DATE.BOOLEAN.RECORD and, if many instances are needed, an ARRAY of that record.FILE of the appropriate RECORD type.REAL with explicit rounding or a fixed‑point representation.INTEGER for values > 2,147,483,647.INTEGER; use STRING instead.WRITE when you intend to READ will erase existing data.Effective problem solving begins with a careful analysis of the data involved. By matching each piece of information to the most appropriate primitive or derived type, documenting the choice in an identifier table, and grouping related items into a well‑defined RECORD (with optional ARRAY and FILE handling), students produce programs that are clear, efficient, and fully aligned with the Cambridge AS & A‑Level Computer Science 9618 syllabus.
ARRAY[lower..upper] OF <type>. The number of elements is upper – lower + 1.INTEGER, REAL, CHAR, STRING, BOOLEAN, DATE or any RECORD.
DECLARE scores : ARRAY[1..10] OF INTEGER
FOR i ← 1 TO 10 DO
scores[i] ← 0 // initialise each element
ENDFOR
PROCEDURE bubbleSort(arr : ARRAY[1..n] OF INTEGER, n : INTEGER)
DECLARE i, j, temp : INTEGER
FOR i ← 1 TO n-1 DO
FOR j ← 1 TO n-i DO
IF arr[j] > arr[j+1] THEN
temp ← arr[j]
arr[j] ← arr[j+1]
arr[j+1] ← temp
ENDIF
ENDFOR
ENDFOR
ENDPROCEDURE
FUNCTION linearSearch(arr : ARRAY[1..n] OF INTEGER, n : INTEGER, key : INTEGER) RETURNS INTEGER
DECLARE i : INTEGER
FOR i ← 1 TO n DO
IF arr[i] = key THEN
RETURN i // position of the key
ENDIF
ENDFOR
RETURN 0 // 0 indicates “not found”
ENDFUNCTION
Book record)| Identifier | Type | Description |
|---|---|---|
| library | ARRAY[1..1000] OF Book | Collection of up to 1000 books |
| numberOfBooks | INTEGER | Current number of valid entries in library |
READ/WRITE loops are used; suitable for most Cambridge exam questions.SEEK or by reopening the file and reading until the desired index is reached. Random access is not required for the 9618 exam but understanding the concept helps avoid logical errors.DECLARE bookFile : FILE OF Book
FOR READ – open for reading; file must already exist.FOR WRITE – open for writing; existing content is erased.FOR APPEND – open for writing, but new records are added after the existing ones.
PROCEDURE readBookByIndex(fileName : STRING, index : INTEGER) RETURNS Book
DECLARE bookFile : FILE OF Book
DECLARE temp : Book
OPEN fileName FOR READ AS bookFile
FOR i ← 1 TO index DO
READ bookFile INTO temp
IF EOF(bookFile) THEN
CLOSE bookFile
RETURN null // index out of range
ENDIF
ENDFOR
CLOSE bookFile
RETURN temp
ENDPROCEDURE
WRITE mode when you only need to read – this overwrites the file.CLOSE a file – may lead to data loss or file‑handle exhaustion.EOF before a READ – can cause run‑time errors.An abstract data type defines a set of values and the operations that can be performed on those values, without specifying how the operations are implemented. In the Cambridge syllabus the focus is on the logical behaviour of three ADTs:
PUSH, POP, TOP, IS_EMPTY.ENQUEUE, DEQUEUE, FRONT, IS_EMPTY.INSERT, DELETE, SEARCH, TRAVERSE.
DECLARE stack : ARRAY[1..MAX] OF INTEGER
DECLARE top : INTEGER ← 0
PROCEDURE push(value : INTEGER)
IF top = MAX THEN
// stack overflow – handle as required
ELSE
top ← top + 1
stack[top] ← value
ENDIF
ENDPROCEDURE
FUNCTION pop() RETURNS INTEGER
IF top = 0 THEN
// stack underflow – handle as required
RETURN -1
ELSE
pop ← stack[top]
top ← top - 1
ENDIF
ENDFUNCTION
DECLARE queue : ARRAY[1..MAX] OF INTEGER
DECLARE front, rear, count : INTEGER ← 0
PROCEDURE enqueue(value : INTEGER)
IF count = MAX THEN
// queue full
ELSE
rear ← (rear MOD MAX) + 1
queue[rear] ← value
count ← count + 1
ENDIF
ENDPROCEDURE
FUNCTION dequeue() RETURNS INTEGER
IF count = 0 THEN
// queue empty
RETURN -1
ELSE
front ← (front MOD MAX) + 1
dequeue ← queue[front]
count ← count - 1
ENDIF
ENDFUNCTION
data : <type> and next : POINTER TO Node.next references rather than array indexes.INTEGER, REAL, CHAR, STRING, BOOLEAN or DATE.RECORD and write a clear identifier table.ARRAY of that record type and include an identifier table for the array.FILE. State the purpose, the mode (READ/WRITE/APPEND) and show at least one OPEN/READ/WRITE/CLOSE sequence.Student record showing the byte offset of each field (illustrative only).Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.