Upgrade to access all Cambridge 9618 lessons including pseudocode, trace tables, and programming content.
Upgrade to Pro →Cambridge 9618 has a very specific pseudocode syntax that must be used in Paper 2. Deviation from these conventions will lose marks. The complete syntax is covered below.
DECLARE x : INTEGER DECLARE name : STRING DECLARE score : REAL DECLARE flag : BOOLEAN DECLARE ch : CHAR
x ← 10 name ← "Alice" score ← 98.5 flag ← TRUE ch ← 'A'
INPUT x INPUT name
OUTPUT x OUTPUT "Hello ", name OUTPUT "Score: ", score
A trace table is a manual simulation of algorithm execution. You create a column for each variable and track how values change line-by-line. Cambridge exam questions ask you to complete trace tables — marks are lost for missing rows or wrong variable values.
A[2])Completed trace table:
| x | y | x <= 4? | OUTPUT |
|---|---|---|---|
| 1 | 0 | ||
| TRUE | |||
| 1 | |||
| 2 | |||
| TRUE | |||
| 3 | |||
| 3 | |||
| TRUE | |||
| 6 | |||
| 4 | |||
| TRUE | |||
| 10 | |||
| 5 | |||
| FALSE | |||
| 10 |
The algorithm sums 1+2+3+4 = 10. The trace shows y accumulating the sum, and x incrementing until x=5 makes the WHILE condition false.
| Construct | Cambridge 9618 Syntax | Notes |
|---|---|---|
| Assignment | x ← 5 | Use ← not = or := |
| Comparison | x = 5 | = used for equals comparison in conditions |
| Not equal | x <> 5 | Not != or ≠ |
| AND/OR/NOT | AND OR NOT | Always uppercase keywords |
| String concat | str1 & str2 | Ampersand for concatenation |
| Integer divide | x DIV y | Truncates to integer |
| Modulo | x MOD y | Remainder after division |
| For loop | FOR i ← 1 TO 10 ... NEXT i | NEXT not ENDFOR |
| For with step | FOR i ← 10 TO 1 STEP -2 | STEP can be negative |
| While loop | WHILE cond DO ... ENDWHILE | Condition checked before body |
| Repeat loop | REPEAT ... UNTIL cond | Condition checked after body (runs at least once) |
| IF statement | IF cond THEN ... ELSE ... ENDIF | ELSE is optional |
| CASE statement | CASE var OF 'A': ... ENDCASE | OTHERWISE for default |
| Array | DECLARE A : ARRAY[1:10] OF INTEGER | 1-indexed by default |
| 2D array | DECLARE M : ARRAY[1:3,1:3] OF REAL | Row, Column indexing |
| Procedure | PROCEDURE name(p:T) ... ENDPROCEDURE | Called with CALL |
| Function | FUNCTION f(p:T) RETURNS T ... ENDFUNCTION | Must have RETURNS keyword |
= for assignment — always use ←ENDFOR — Cambridge uses NEXT iRETURNS type and RETURN value; procedures don't return a valueDECLARE name : TYPE6 questions · instantly marked · Cambridge 9618 standard
total of type REAL, assign it the value 0, then add 3.5 to it three times using a WHILE loop.[5]Cube that takes an integer parameter n and returns n³.[3]INPUT a
INPUT b
WHILE a > b DO
a ← a - b
ENDWHILE
OUTPUT a[4]DIV and MOD? Give an example of each using the values 17 and 5.[4]PrintSquares that takes a parameter n : INTEGER and outputs the square of each integer from 1 to n.[4]| Term | Definition |
|---|
10 questions · 10 marks · 10 minutes