The Ultimate Pseudocode Syntax Guide for Paper 2

What are the three main constructs of programming?
Table of Contents
Paper 2 (Problem-solving and Programming) is built entirely around CAIE's specific flavor of pseudocode. If you write Python or Java code in the exam, you will lose marks for not using the standardized syntax. This cheat sheet from our Ultimate O-Level Computer Science Guide gives you the exact syntax rules.
1. Declaring Variables and Assignment
Before you use a variable in pseudocode, you generally must DECLARE it and assign it a data type (INTEGER, REAL, STRING, CHAR, BOOLEAN).
DECLARE Average : REAL
DECLARE PlayerName : STRING
TotalScore <- 0
PlayerName <- "John"
OUTPUT "Hello, ", PlayerName
<-. The equals sign is strictly reserved for comparing things (e.g. IF Score = 100).2. Selection (IF and CASE statements)
Selection allows your code to make decisions. Every IF statement must end with an ENDIF.
The IF/THEN/ELSE Structure
OUTPUT "Pass!"
ELSE
OUTPUT "Fail. Try again."
ENDIF
The CASE Structure
If you have many different options (like a menu system), an IF statement gets very messy and nested. Use a CASE statement instead.
1 : OUTPUT "Starting Game"
2 : OUTPUT "Loading Save"
3 : OUTPUT "Exiting"
OTHERWISE : OUTPUT "Invalid option chosen"
ENDCASE
3. Iteration (The 3 Types of Loops)
Iteration means repeating a sequence of code. You must choose the right loop for the right scenario.
1. The FOR Loop (Count-Controlled)
Use this when you know EXACTLY how many times the loop needs to run (e.g., asking exactly 10 students for their age). It automatically increments the counter.
OUTPUT "Enter age:"
INPUT Age
NEXT Counter
2. The WHILE Loop (Pre-Condition)
Use this when you don't know how many times the loop will run. High risk of infinite loops! The condition is checked at the start. If it is false immediately, the loop runs ZERO times.
OUTPUT "Wrong password, try again:"
INPUT Password
ENDWHILE
3. The REPEAT-UNTIL Loop (Post-Condition)
Checks the condition at the END. Therefore, it is guaranteed to run AT LEAST ONCE. Excellent for user input validation.
OUTPUT "Enter a number between 1 and 10:"
INPUT Num
UNTIL Num >= 1 AND Num <= 10
<>. Do not write != like in Python/JavaScript.Frequently Asked Questions
What is the difference between = and <- in Pseudocode?▼
What is the difference between a WHILE loop and a REPEAT-UNTIL loop?▼
How do you declare a 1D Array in O-Level Pseudocode?▼
Why must you indent pseudocode?▼
Stop Guessing, Start Scoring
Get instant access to 500+ CAIE-aligned practice questions, worked solutions, and AI-powered mock exams across all O-Level subjects.