This set of notes covers all required sub‑topics for Topics 1‑10 of the Cambridge IGCSE Computer Science (0478) syllabus. It is written in the Cambridge‑style pseudocode conventions, includes clear examples, tables, and test‑data strategies, and highlights the limits imposed by the syllabus (e.g., parameters, nesting depth, circuit inputs).
+-------------------+
| Main Program |
+-------------------+
| Initialise() |
| GetData() |
| ProcessData() |
| OutputResult() |
+-------------------+
FOR loop that adds the numbers 1‑5:
| Step | i | sum |
|---|---|---|
| Initialise | – | 0 |
| 1st iteration | 1 | 0 + 1 = 1 |
| 2nd iteration | 2 | 1 + 2 = 3 |
| 3rd iteration | 3 | 3 + 3 = 6 |
| 4th iteration | 4 | 6 + 4 = 10 |
| 5th iteration | 5 | 10 + 5 = 15 |
| Loop ends | – | 15 |
// Validate age input
READ age
IF age < 0 OR age > 120 THEN
PRINT "Invalid age"
STOP
END IF
TRUE or FALSE.CONST keyword and written in ALL CAPS:
CONST MAX_STUDENTS ← 30
CONST TAX_RATE ← 0.20
// and are ignored by the interpreter.IF, FOR, WHILE, etc.
// Calculate average mark
FOR i ← 1 TO n DO
total ← total + marks[i]
END FOR
average ← total / n
| Category | Operator(s) | Example |
|---|---|---|
| Arithmetic | +, –, *, /, % | area ← length * width |
| Relational | =, ≠, <, >, ≤, ≥ | IF score ≥ 50 THEN … |
| Logical | AND, OR, NOT | IF age ≥ 18 AND citizen = TRUE THEN … |
READ variable – obtains a value from the user.PRINT … – displays text and/or variable values.IF inside another loop).
// Procedure – no return value
PROCEDURE DisplayHeader()
PRINT "=== STUDENT MARKS ==="
END PROCEDURE
// Function – returns a value
FUNCTION Max(a, b) RETURNS INTEGER
IF a > b THEN
RETURN a
ELSE
RETURN b
END IF
END FUNCTION
IF condition THEN
statements
END IF
IF condition THEN
statements1
ELSE
statements2
END IF
IF cond1 THEN
statements1
ELSE IF cond2 THEN
statements2
ELSE
statements3
END IF
FOR i ← start TO end STEP step DO
statements
END FOR
WHILE condition DO
statements
END WHILE
REPEAT
statements
UNTIL condition
The default flow of a program – each statement is executed once, top to bottom, unless a later control structure changes the order.
Allows a program to choose actions based on a Boolean condition.
| Form | Pseudocode | Typical Use |
|---|---|---|
Simple IF |
IF condition THEN
statements
END IF |
Execute a block only when the condition is true. |
IF‑ELSE |
IF condition THEN
statements1
ELSE
statements2
END IF |
Choose between two alternatives. |
| Nested selection | IF cond1 THEN
IF cond2 THEN
statements
END IF
END IF |
Decision inside another decision (max 3 levels). |
Multiple selection (ELSE IF) |
IF cond1 THEN
statements1
ELSE IF cond2 THEN
statements2
ELSE
statements3
END IF |
More than two alternatives. |
Repeats a block of statements. Choose the loop type that best matches the known information about the number of repetitions.
| Loop type | Pseudocode | When to use |
|---|---|---|
| WHILE (pre‑test) | WHILE condition DO
statements
END WHILE |
Number of repetitions unknown; loop may execute zero times. |
| FOR (counter‑controlled) | FOR i ← start TO end STEP step DO
statements
END FOR |
Exact number of repetitions known; i is the loop counter. |
| REPEAT‑UNTIL (post‑test) | REPEAT
statements
UNTIL condition |
Loop must execute at least once. |
DECLARE Scores : ARRAY[1:10] OF INTEGER // 10 elements, indexed 1‑10
Scores[i] where i is an integer within the declared bounds.FOR i ← 1 TO 10 DO
READ Scores[i]
END FOR
max ← Scores[1]
FOR i ← 2 TO 10 DO
IF Scores[i] > max THEN
max ← Scores[i]
END IF
END FOR
total ← 0
FOR i ← 1 TO 10 DO
total ← total + Scores[i]
END FOR
average ← total / 10
found ← FALSE
FOR i ← 1 TO 10 DO
IF Scores[i] = target THEN
found ← TRUE
EXIT FOR
END IF
END FOR
Cambridge pseudocode distinguishes between INPUT (reading) and OUTPUT (writing) modes. A file must be opened before any read/write operation and closed afterwards.
| Statement | Purpose |
|---|---|
OPEN file_name FOR INPUT | Open an existing text file for reading. |
OPEN file_name FOR OUTPUT | Create a new file (or overwrite an existing one) for writing. |
READ file_name, variable | Read the next record from the file into variable. |
WRITE file_name, variable | Write the value of variable as a new record. |
CLOSE file_name | Close the file and release the resource. |
Example – Store 5 marks in a file and then display them:
// Write marks to file
OPEN "marks.txt" FOR OUTPUT
FOR i ← 1 TO 5 DO
READ mark
WRITE "marks.txt", mark
END FOR
CLOSE "marks.txt"
// Read marks back and display
OPEN "marks.txt" FOR INPUT
FOR i ← 1 TO 5 DO
READ "marks.txt", mark
PRINT "Mark", i, "=", mark
END FOR
CLOSE "marks.txt"
Example – Table definition (Cambridge style description)
Table: Students
Fields:
StudentID : INTEGER // Primary key, >0, unique
Name : VARCHAR(30)
Age : INTEGER // 5 ≤ Age ≤ 120
Mark : INTEGER // 0 ≤ Mark ≤ 100
| Purpose | SQL (Cambridge style) |
|---|---|
| List all records ordered by a field | SELECT * FROM Students ORDER BY Mark DESC; |
| Count records that meet a condition | SELECT COUNT(*) FROM Students WHERE Mark ≥ 80; |
| Sum a numeric field | SELECT SUM(Mark) FROM Students; |
| Find a specific record | SELECT * FROM Students WHERE StudentID = 3; |
| Insert a new record | INSERT INTO Students (StudentID, Name, Age, Mark) VALUES (4, 'David', 17, 73); |
| Update a field | UPDATE Students SET Mark = 88 WHERE StudentID = 2; |
| Delete a record | DELETE FROM Students WHERE StudentID = 5; |
Age must be between 5 and 120).| Operator | Symbol | Result |
|---|---|---|
| AND | ∧ | TRUE only when both operands are TRUE |
| OR | ∨ | TRUE when at least one operand is TRUE |
| NOT | ¬ | Inverts the operand |
(A AND NOT B) OR (B AND NOT A):
A ──► AND ──► OR ──► Output
│ │
NOT B B
│
NOT A
Given a truth table, write the minimal Boolean expression and then draw the corresponding circuit.
Exercise – Complete the truth table for (A AND NOT B) OR (B AND NOT A). The completed table is the XOR function:
| A | B | NOT B | A AND NOT B | NOT A | B AND NOT A | Result |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 | 0 |
Decimal 13 = 1·2³ + 1·2² + 0·2¹ + 1·2⁰ → 1101₂
1011 1100₂ = BC₁₆
+7 = 0000 0111₂
-7 = invert bits → 1111 1000₂
add 1 → 1111 1001₂
± mantissa × 2^exponent. IGCSE expects only a conceptual understanding.'A' = 65₁₀ = 01000001₂.IF‑ELSE, FOR, WHILE and REPEAT‑UNTIL loops?Use this checklist to identify any weak areas before the exam. Good luck!
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.