All languages examined in the Cambridge IGCSE (0478) follow the same basic rules. In the exam identifiers are case‑insensitive – total and TOTAL are treated as the same name.
| Rule | Description |
|---|---|
| Start with a letter | First character must be A‑Z or a‑z. |
| Allowed characters | After the first character you may use letters, digits (0‑9) and the underscore _. |
| No spaces | Use camelCase (e.g. studentScore) or underscores (e.g. student_score) to separate words. |
| Case‑insensitivity (exam) | Upper‑case and lower‑case are considered the same (total = TOTAL). |
| Reserved words | Keywords such as IF, WHILE, INTEGER, DECLARE etc. cannot be used as identifiers. |
Cambridge pseudocode syntax
DECLARE age AS INTEGER
DECLARE price AS REAL
DECLARE name AS STRING
CONSTANT MAX_SCORE ← 100
CONSTANT PI ← 3.14159
Note:
←. = is never used for assignment.| Data Type | Typical Size (bits) | Range / Example Values |
|---|---|---|
| INTEGER | 16 or 32 | ‑215 … 215‑1 (16‑bit) or ‑231 … 231‑1 (32‑bit) |
| REAL (floating‑point) | 32 (single precision) | ≈ ±3.4 × 1038 with about 6‑7 decimal digits of precision |
| CHARACTER | 8 | Single letters or symbols, e.g. 'A' |
| STRING | Variable | Sequences of characters, e.g. "Hello" |
| BOOLEAN | 1 | TRUE or FALSE |
After a variable has been declared you give it a value with ←. The value may be changed later.
age ← 15 // first assignment
age ← age + 1 // re‑assignment, now age = 16
Cambridge pseudocode uses the keywords INPUT and OUTPUT. The prompt is written in quotation marks.
INPUT "Enter the student's score: ", score
OUTPUT "Result: ", result
OUTPUT "Score = ", score, ", Grade = ", grade
| Category | Operator(s) | Purpose | Example |
|---|---|---|---|
| Arithmetic | +, –, *, /, % | Basic maths | total ← a + b * c |
| Relational | =, <>, <, ≤, >, ≥ | Compare two values | IF score ≥ PASS_MARK THEN … |
| Logical (Boolean) | AND, OR, NOT | Combine Boolean expressions | IF (age ≥ 18) AND (hasID = TRUE) THEN … |
IF score ≥ PASS_MARK THEN
result ← "Pass"
ELSE
result ← "Fail"
ENDIF
CASE grade OF
"A": OUTPUT "Excellent"
"B": OUTPUT "Good"
"C": OUTPUT "Average"
"D","E","F": OUTPUT "Needs Improvement"
ENDCASE
Repeat a block of code while a condition holds.
FOR i ← 1 TO 10 STEP 1 DO
total ← total + i
ENDFOR
An array stores a collection of values of the same type. The lower and upper bounds must be stated explicitly.
DECLARE marks[1..30] AS INTEGERDECLARE matrix[1..5,1..5] AS REALmarks[5] ← 78 or matrix[2,3] ← 3.5FOR i ← 1 TO 30 DO
INPUT "Enter mark ", i, ": ", marks[i]
ENDFOR
Only the operations required for the syllabus are listed. A complete open‑read‑close cycle is shown.
OPEN "scores.txt" FOR READ
READ "scores.txt", mark1
READ "scores.txt", mark2
// … process data …
CLOSE "scores.txt"
OPEN fileName FOR READ – open an existing file for reading.OPEN fileName FOR WRITE – create (or overwrite) a file for writing.READ fileName, variable – read the next value from the file.WRITE fileName, variable – write a value to the file.CLOSE fileName – close the file when finished.| Routine | Purpose | Example |
|---|---|---|
| ROUND(x) | Round a real number to the nearest integer | rounded ← ROUND(3.7) // 4 |
| RANDOM() | Return a pseudo‑random real number between 0 and 1 | r ← RANDOM() |
| LENGTH(s) | Number of characters in a string | len ← LENGTH("hello") // 5 |
| LCASE(s), UCASE(s) | Convert a string to lower‑case / upper‑case | lower ← LCASE("AbC") // "abc" |
| SUBSTRING(s, start, length) | Extract a part of a string | sub ← SUBSTRING("Cambridge", 1, 4) // "Cam" |
| INT(x) | Truncate a real number to an integer (discard the fractional part) | i ← INT(7.9) // 7 |
Before using data, check that it meets the required criteria (validation). After data has been read, additional checks such as a checksum are called verification.
Five common validation checks:
INPUT "Enter age (0‑120): ", age
IF (age < 0) OR (age > 120) THEN
OUTPUT "Invalid age – please re‑enter."
// repeat input or abort
ENDIF
Verification example (checksum after reading a file):
READ "data.txt", value, checksum
IF (value MOD 10) ≠ checksum THEN
OUTPUT "Data corrupted – abort."
ENDIF
A trace table records the values of variables after each step of a program. It helps you verify logic and spot errors before writing code.
| Step | age | total | output |
|---|---|---|---|
| 1 – INPUT | 15 | – | – |
| 2 – age ← age + 1 | 16 | – | – |
| 3 – total ← total + age | 16 | 16 | – |
| 4 – OUTPUT | 16 | 16 | "Age is 16, total is 16" |
= instead of ← for assignment in exam pseudocode.1..30).DO and ENDFOR (or ENDWHILE, ENDREPEAT) keywords in loops.← for assignment – never use =.IF…THEN…ELSE or CASE…OF) for the problem.FOR … DO … ENDFOR, etc.).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.