← for assignment.| Syllabus Item | Present in Notes? | Action Required |
|---|---|---|
| INPUT / READ | Yes | – |
| WRITE / PRINT | Yes | – |
| FOR … NEXT | Yes | – |
| FOR … NEXT … STEP | No | Added in “Looping Constructs”. |
| IF … ELSE … ENDIF | No | Added in “Decision‑Making”. |
| WHILE … END WHILE | Yes | – |
| REPEAT … UNTIL | No | Added in “Looping Constructs”. |
| CASE … ENDCASE | No | Added in “Decision‑Making”. |
| Comparison & arithmetic operators | Implicit | Explicit table added. |
| Sub‑routines / procedures | No | New “Sub‑routines” section introduced. |
| Editing a given algorithm / flowchart | No | Spot‑the‑error exercises added. |
| Nested decisions | No | Example with grading added. |
| Statement | Purpose | Example |
|---|---|---|
INPUT / READ | Read data from the user or a file | INPUT n |
WRITE / PRINT | Display data on the screen | WRITE "Result =", result |
FOR i = start TO end | Loop a known number of times (increment = 1) | FOR i = 1 TO n |
FOR i = start TO end STEP step | Loop with a user‑defined increment or decrement | FOR i = 10 TO 0 STEP -2 |
END FOR | Terminate a FOR loop | END FOR |
WHILE condition | Repeat while the condition is true (test before first iteration) | WHILE total < limit |
END WHILE | Terminate a WHILE loop | END WHILE |
REPEAT | Start a loop that executes at least once | REPEAT |
UNTIL condition | Terminate a REPEAT loop when the condition becomes true (test after each iteration) | UNTIL password = "Cambridge" |
IF condition THEN | Single‑branch decision | IF score ≥ 50 THEN |
ELSE | Alternative branch for an IF | ELSE |
ENDIF | Terminate an IF … THEN … ELSE … ENDIF block | ENDIF |
CASE expression OF | Multi‑way selection | CASE choice OF |
WHEN value: | Branch of a CASE | WHEN 1: … |
WHEN OTHER: | Default branch of a CASE | WHEN OTHER: … |
ENDCASE | Terminate a CASE block | ENDCASE |
CALL subroutine (parameters) | Invoke a sub‑routine | CALL Factorial (n, result) |
PROCEDURE subroutine (parameters) | Define a sub‑routine | PROCEDURE Factorial (n, result) |
END PROCEDURE | Terminate a sub‑routine definition | END PROCEDURE |
| Operator | Meaning |
|---|---|
= | Equal to |
≠ or # | Not equal to |
< | Less than |
> | Greater than |
≤ | Less than or equal to |
≥ | Greater than or equal to |
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
MOD | Remainder after integer division |
| Symbol | Name | Represents |
|---|---|---|
| 🟠 (Oval) | Terminator | Start or End of the process |
| ▭ (Parallelogram) | Input/Output | INPUT or WRITE |
| ▭ (Rectangle) | Process | Assignment, calculation or sub‑routine call |
| ◇ (Diamond) | Decision | Any conditional test – IF, WHILE, REPEAT…UNTIL, CASE |
| ⇆ (Connector) | Arrow | Shows flow direction |
| ⧉ (Circle) | Sub‑routine | Call and return points for procedures |
INPUT (or READ) to obtain data.WRITE (or PRINT) to display results.PROCEDURE … END PROCEDURE.CALL.IF has a corresponding ENDIF (and an ELSE if required).←.WHILE or REPEAT…UNTIL.IF … THEN … ELSE … ENDIF or CASE.FOR … END FOR, WHILE … END WHILE or REPEAT … UNTIL.INPUT or WRITE.CALL statement and verify that a matching PROCEDURE … END PROCEDURE exists.INPUT n
total ← 0
FOR i = 1 TO n
total ← total + i
END FOR
WRITE "Sum =", total
INPUT n
total ← 0
FOR i = 2 TO n STEP 2
total ← total + i
END FOR
WRITE "Even sum =", total
INPUT a
INPUT b
WHILE b ≠ 0
temp ← b
b ← a MOD b
a ← temp
END WHILE
WRITE "GCD =", a
REPEAT
INPUT password
UNTIL password = "Cambridge"
WRITE "Access granted"
WRITE "1 – Add 2 – Subtract 3 – Exit"
INPUT choice
CASE choice OF
WHEN 1:
INPUT a, b
result ← a + b
WRITE "Result =", result
WHEN 2:
INPUT a, b
result ← a - b
WRITE "Result =", result
WHEN 3:
WRITE "Good‑bye"
WHEN OTHER:
WRITE "Invalid choice"
ENDCASE
INPUT score
IF score ≥ 80 THEN
grade ← "A"
ELSE
IF score ≥ 70 THEN
grade ← "B"
ELSE
IF score ≥ 60 THEN
grade ← "C"
ELSE
grade ← "F"
ENDIF
ENDIF
ENDIF
WRITE "Grade =", grade
PROCEDURE Factorial (n, result)
result ← 1
FOR i = 2 TO n
result ← result * i
END FOR
END PROCEDURE
INPUT n
CALL Factorial (n, fact)
WRITE "Factorial of", n, "is", fact
INPUT n
total ← 0
FOR i = 1 TO n‑1
total ← total + i
END FOR
WRITE total
Error: Loop stops at n‑1; the sum of the first n numbers is incomplete.
Correction: Change FOR i = 1 TO n‑1 to FOR i = 1 TO n.
REPEAT
INPUT answer
WRITE "Try again"
UNTIL answer = correct
WRITE "Correct!"
Error: The message “Try again” is printed even when the first answer is correct.
Fix: Move the WRITE statement after the test, or replace the structure with a WHILE loop:
INPUT answer
WHILE answer ≠ correct
WRITE "Try again"
INPUT answer
END WHILE
WRITE "Correct!"
Correction: Add a second arrow labelled “No” that leads to the WRITE symbol (or the terminator).
INPUT x
IF x > 0 THEN
WRITE "Positive"
ELSE
IF x = 0 THEN
WRITE "Zero"
END IF
Error: Two IF statements but only one ENDIF. The inner IF is not closed.
Fix: Add an additional ENDIF after the “Zero” branch.
FOR loop.END statements.CASE … ENDCASE for the menu and appropriate loops to allow repeated use until the user chooses “Exit”.IsPrime that takes an integer n and returns TRUE if n is a prime number, otherwise FALSE. Show how you would call this procedure from a main algorithm.INPUT n
i ← 2
WHILE i ≤ n
IF n MOD i = 0 THEN
WRITE n, "is not prime"
ENDIF
i ← i + 1
END WHILE
WRITE n, "is prime"
FOR loops always require END FOR; WHILE requires END WHILE; REPEAT pairs with UNTIL.IF structures terminate with ENDIF; include ELSE only when a second branch is required.WHILE or REPEAT…UNTIL; when it splits, use IF…ELSE or CASE.END statements.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.