Assignment – the operation that stores the result of an expression in a variable, using the operator ←.
Variable name – an identifier that follows the board’s naming rules.
Type‑compatible – the right‑hand side expression must be of the same data type as the variable, or be one of the permitted implicit conversions.
Constant – a named value that cannot be altered after its initial definition; it may appear on the right‑hand side of := but never on the left.
Built‑in function – a predefined operation (e.g. LEN(), INT()) that can be used in an expression.
Although many exam questions omit explicit declarations, the board expects you to understand the syntax.
| Purpose | Pseudocode |
|---|---|
| Declare an integer variable | DECLARE counter: INTEGER |
| Declare and initialise a real variable | DECLARE radius : REAL |
Define a constant (cannot be on the left‑hand side of ←) | CONSTANT PI ← 3.14159 |
| Declare an array of five integers | DECLARE marks: ARRAY[1:5] OF INTEGER |
| Declare a record type |
|
The assignment operator in Cambridge pseudocode is ←. The general form is:
variable ← expression
After execution, variable holds the value produced by expression
_).IF, FOR, PROCEDURE.| Data Type | Literal Example | Description |
|---|---|---|
| Integer | 42 | Whole numbers, positive or negative. |
| Real | 3.14 | Numbers with a fractional part. |
| Boolean | TRUE, FALSE | Logical values. |
| String | "Hello" | Sequence of characters enclosed in double quotes. |
Only the following implicit conversions are allowed:
| From (source) | To (target) | Result |
|---|---|---|
| Integer | Real | Integer automatically becomes a real (e.g. 5 = 5.0). |
| Character | String | Single character becomes a one‑character string. |
| Boolean | Integer / Real | TRUE → 1, FALSE → 0. |
All other conversions cause a type error.
INT()) or redesign the expression.DECLARE age: INTEGER
age ← 18
INTEGER a, b, sum
a ← 7
b ← 5
sum ← a + b // sum now holds 12
DECLARE counter : INTEGER
counter ← 0
counter ← counter + 1 // increment
counter ← counter * 2 // double
DECLARE scores: ARRAY[1:5] OF INTEGER
i ← 3
scores[i] ← 87 // stores 87 in the 4th element (indexing starts at 0)
TYPE student
DECLARE name: STRING
DECLARE mark: INTEGER
ENDTYPE
DECLARE thisStudent ← : student
thisStudent.name ← "Bob"
thisStudent.mark ← 73
DECLARE radius, area: REAL
radius ← 3.5
area ← 3.14159 * radius * radius // πr²
DECLARE firstName, lastName, fullName : STRING
firstName ← "Ada"
lastName ← "Lovelace"
fullName ← firstName & " " & lastName // "Patrick Smith"
DECLARE score: INTEGER
DECLARE isPass: BOOLEAN
score ← 78
isPass ← score >= 50 // TRUE
DECLARE name : STRING
DECLARE length : INTEGER
INPUT name
length ← LEN(name) // LEN returns the number of characters
OUTPUT "The name has ", length, " letters."
Below is a compact algorithm that demonstrates declaration, input, assignment, a loop, array usage and output.
PROCEDURE ReadMarksAndTotal()
DECLARE i, total : INTEGER
DECLARE marks: ARRAY[1:5] OF INTEGER
total ← 0
FOR i ← 0 TO 4
READ marks[i] // input each mark
total ← total + marks[i] // accumulate using assignment
NEXT i
OUTPUT "Total of the 5 marks = ", total
ENDPROCEDURE
= instead of := for assignment.counter and initialise it to 0.TRUE in a Boolean variable passed if the mark is 40 or above.REAL length, width, area, assign the product of length and width to area.greeting that concatenates the word “Hello”, a space, and a variable name (which already holds a student's name).x, y, z to the values 10, 20, and 30 respectively.marks[5] using a loop.student with fields name (STRING) and score (INTEGER), write pseudocode that updates student.score to the value stored in variable newScore.word, uses the built‑in function LEN() to find its length, and writes “Length = ” followed by the length.REAL).