Structured English combines plain English with a limited set of control‑flow keywords. It is:
IF, FOR EACH, WHILE, REPEAT.| Structured English | Pseudocode |
|---|---|
| SET variable TO expression | variable ← expression |
| IF condition THEN … ELSE … END IF | if condition then … else … endif |
| FOR EACH item IN list DO … END FOR | for each item in list do … endfor |
| FOR i FROM a TO b DO … END FOR | for i ← a to b do … endfor |
| WHILE condition DO … END WHILE | while condition do … endwhile |
| REPEAT … UNTIL condition | repeat … until condition |
| OUTPUT value | output value |
| CALL procedure(args) | call procedure(args) |
| RETURN value | return value |
if has an endif, every for an endfor, etc.// on a separate line.SET total TO 0
FOR EACH number IN numbers DO
IF number MOD 2 = 0 THEN
SET total TO total + number
END IF
END FOR
OUTPUT total
total ← 0
for each number in numbers do
if number mod 2 = 0 then
total ← total + number
endif
endfor
output total
SET … TO … → assignment arrow ←.FOR EACH … DO … END FOR → for each … do … endfor.IF … THEN … END IF → if … then … endif.MOD) are left unchanged.if, while, for, output).← for assignment; if unavailable, write “=”.// and occupy a whole line.endif, endfor, endwhile, endrepeat).A simple assembly program that adds the elements of an array, together with its register‑transfer notation (RTN) and equivalent pseudocode.
; --- Assembly (pseudo‑ASM) ---------------------------------
LDI R0,0 ; sum ← 0
LDI R1,0 ; i ← 0
LOOP: CMP R1,N
JGE END
LDA R2,ARRAY(R1)
ADD R0,R2
INC R1
JMP LOOP
END: STA SUM,R0
; ---------------------------------------------------------
Corresponding pseudocode:
sum ← 0
i ← 0
while i < N do
sum ← sum + ARRAY[i]
i ← i + 1
endwhile
| Component | Key Functions (Cambridge) |
|---|---|
| Operating System | Memory management, file system, process scheduling, device control, security services. |
| Compilers | Translate source → object code; optimisation; produce executables. |
| Interpreters | Execute source line‑by‑line; useful for rapid testing. |
| Assemblers | Translate symbolic assembly → machine code. |
| IDE Features | Syntax highlighting, debugger, auto‑completion – helpful for testing pseudocode. |
Case study – Software licences
Discussion prompt for exams: “Explain how open‑source licences balance the creator’s rights with public benefit.”
SELECT name, score
FROM Students
WHERE score > 80
ORDER BY score DESC;
| Category | Examples |
|---|---|
| Primitive types | INTEGER, REAL, BOOLEAN, CHARACTER, STRING |
| Composite types | RECORD (struct), ARRAY (1‑D, 2‑D), LIST |
| Abstract Data Types | STACK, QUEUE, LINKED LIST (brief description) |
| File handling (pseudocode) |
|
found ← false
i ← 0
while i < length(list) and not found do
if list[i] = target then
found ← true
endif
i ← i + 1
endwhile
output found
low ← 0
high ← length(list) - 1
found ← false
while low <= high and not found do
mid ← (low + high) div 2
if list[mid] = target then
found ← true
elseif list[mid] < target then
low ← mid + 1
else
high ← mid - 1
endif
endwhile
output found
for i ← 0 to length(arr) - 2 do
for j ← 0 to length(arr) - i - 2 do
if arr[j] > arr[j+1] then
temp ← arr[j]
arr[j] ← arr[j+1]
arr[j+1] ← temp
endif
endfor
endfor
output arr
for i ← 1 to length(arr) - 1 do
key ← arr[i]
j ← i - 1
while j >= 0 and arr[j] > key do
arr[j+1] ← arr[j]
j ← j - 1
endwhile
arr[j+1] ← key
endfor
output arr
function factorial(n)
if n = 0 then
return 1
else
return n * factorial(n-1)
endif
endfunction
output factorial(5) // 120
For any algorithm we express the dominant term of its running time as a function of the input size n. Example for linear search:
\[
T(n) = c1 + c2 n \;\;\Longrightarrow\;\; T(n) \in O(n)
\]
try
result ← divide(a, b)
catch DivisionByZeroError
output "Cannot divide by zero"
endtry
Convert the following structured English into correct pseudocode.
SET max TO numbers[1]
FOR i FROM 2 TO LENGTH(numbers) DO
IF numbers[i] > max THEN
SET max TO numbers[i]
END IF
END FOR
OUTPUT max
Answer
max ← numbers[1]
for i ← 2 to length(numbers) do
if numbers[i] > max then
max ← numbers[i]
endif
endfor
output max
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.