Docs

Pseudocode reference

Pseudocode syntax reference

Statements, names, data types, constants, operators, library routines, and block endings supported by the browser compiler.

updated November 2, 2026

Core statements

Use DECLARE for variables, <- for assignment, INPUT for user input, and OUTPUT for displayed values.

Pick Cambridge IGCSE, Cambridge A Level, IB, OCR, or AQA in Settings so the compiler follows that board's notation.

Pseudocode
DECLARE Total : INTEGER
Total <- 0
OUTPUT Total

Names, comments, and layout

Consistent names and layout make a program easier to mark and easier to debug.

  • Write keywords in upper case: IF, FOR, WHILE, PROCEDURE.
  • Write identifiers in PascalCase, starting with a capital letter, such as RowTotal.
  • Don't use underscores in identifiers.
  • Start a comment with //.
  • Indent the body of every block by four spaces.

Data types and constants

Declare a variable with DECLARE Name : TYPE before you use it. Declare a constant with CONSTANT Name <- value. A constant's value must be a literal, not an expression.

TypeHoldsExample
INTEGERA whole number42
REALA number with a fractional part3.142
CHARA single character'M'
STRINGText of any length"Mai"
BOOLEANA truth valueTRUE or FALSE
Pseudocode
CONSTANT Pi <- 3.142
DECLARE Radius : REAL
DECLARE Initial : CHAR
DECLARE Name : STRING
DECLARE Passed : BOOLEAN
Radius <- 2.5
Initial <- 'M'
Name <- "Mai"
Passed <- TRUE
OUTPUT Name, " ", Initial, " ", Pi * Radius ^ 2, " ", Passed

Operators

Comparisons and logical operators produce a BOOLEAN, so you can use them directly in IF, WHILE, and UNTIL conditions.

KindOperators
Arithmetic+ - * / ^
Integer divisionDIV(a, b) gives the whole-number quotient; MOD(a, b) gives the remainder
Comparison= < <= > >= <>
LogicalAND OR NOT

Library routines

These routines are built in and appear in autocomplete. ROUND returns a REAL, so store its result in a REAL variable.

RoutineReturns
LENGTH(Text)The number of characters in a string
LCASE(Text), UCASE(Text)The string in lower or upper case
SUBSTRING(Text, Start, Length)Part of a string; the first character is position 1
ROUND(Value, Places)A real number rounded to that many decimal places
RANDOM()A random real number from 0 to 1 inclusive
Pseudocode
DECLARE Phrase : STRING
DECLARE Roll : REAL
Phrase <- "Happy Days"
OUTPUT LENGTH(Phrase)
OUTPUT LCASE(Phrase), " ", UCASE(Phrase)
OUTPUT SUBSTRING(Phrase, 1, 5)
OUTPUT ROUND(15.6789, 2)
OUTPUT DIV(17, 5), " ", MOD(17, 5)
Roll <- ROUND(RANDOM() * 5, 0) + 1
OUTPUT Roll

Cheat sheet

Every block has a matching closing keyword. Matching block endings makes programs easier to trace and debug.

StructureOpens withCloses with
SelectionIF ... THENENDIF
Multi-way selectionCASE OF ...ENDCASE
Count-controlled loopFOR ... TO ...NEXT ...
Pre-condition loopWHILE ... DOENDWHILE
Post-condition loopREPEATUNTIL ...
ProcedurePROCEDURE ...ENDPROCEDURE
FunctionFUNCTION ... RETURNS ...ENDFUNCTION