O Level Computer Science 2210 –
Pseudocode Syntax Cheat Sheet
1. Variables and Assignment
x←5
name ← "Ali"
→ Assigns 5 to variable x and "Ali" to name.
Use ← instead of =.
2. Input and Output
INPUT name
→ Asks the user to type something.
OUTPUT "Hello", name
→ Displays Hello followed by the name on screen.
3. IF Statements (Decision Making)
IF score >= 80 THEN
OUTPUT "A"
ELSEIF score >= 70 THEN
OUTPUT "B"
ELSE
OUTPUT "Fail"
ENDIF
→ Makes decisions based on conditions.
4. Loops (Repetition)
FOR i ← 1 TO 5
OUTPUT i
NEXT i
→ Repeats 5 times.
WHILE count <= 5 DO
OUTPUT count
count ← count + 1
ENDWHILE
→ Repeats while a condition is true.
REPEAT
INPUT num
UNTIL num > 0
→ Repeats until a condition becomes true.
5. Arrays
DIM scores[3]
scores[0] ← 50
scores[1] ← 60
scores[2] ← 70
→ Stores multiple values in one variable.
6. Procedures and Functions
PROCEDURE Greet(name)
OUTPUT "Hello", name
ENDPROCEDURE
→ Reusable block that performs an action.
FUNCTION Square(x)
RETURN x * x
ENDFUNCTION
→ Reusable block that returns a value.
7. Comments
// This is a comment
→ Use comments to explain what your code does.