1. Pseudocode in Examined Components
Cambridge pseudocode formatting conventions: font, indentation, uppercase keywords, line numbering, comments, and BNF notation for CAIE CS exams.
The following conventions describe how pseudocode appears in Cambridge examination papers (IGCSE 0478 and AS & A Level 9618).
Font & Indentation
Pseudocode is presented in a monospaced font (e.g. Courier New). Lines are indented by three spaces to indicate nesting within a containing statement.
Case Convention
Keywords are in UPPER CASE (e.g. IF, REPEAT, PROCEDURE). Identifiers use mixed case / camelCase (e.g. NumberOfPlayers). Meta-variables are enclosed in angle brackets < >.
Line Numbering
When lines are numbered, numbers appear to the left and are consecutive. Skipped numbers indicate missing code. Continuation lines are not numbered.
Comments
Comments are preceded by // and continue to the end of the line. Multi-line comments use // on each line. Comments normally appear on a separate line before the code they describe.
// runnable
// SWAP Procedure Example
// this procedure swaps
// values of X and Y
PROCEDURE SWAP(BYREF X : INTEGER, BYREF Y : INTEGER)
DECLARE Temp : INTEGER
Temp <- X // temporarily store X
X <- Y
Y <- Temp
ENDPROCEDURE
DECLARE First, Second : INTEGER
First <- 4
Second <- 9
CALL SWAP(First, Second)
OUTPUT First, ", ", Second