Skip to content

Pseudocode Guide

This guide follows the official Cambridge IGCSE™ Computer Science (0478) syllabus for exams in 2026-2028. Mastering pseudocode is essential for success in Paper 2.

Pseudocode is designed to be readable and consistent. In your exam, it will appear in a fixed-width font (like Courier New).

Indentation is used to show which statements belong together (e.g., inside a loop or an IF statement).

  • Standard indentation is four spaces.
  • THEN and ELSE clauses are only indented by two spaces.
  • Keywords are always in UPPER CASE (e.g., IF, WHILE, PROCEDURE).
  • Identifiers (names for variables, constants, etc.) use PascalCase (e.g., TotalToPay, StudentName).
  • Identifiers must start with a capital letter and can only contain letters and digits (no underscores).

Use two forward slashes // to add notes to your code.

// This is a single line comment
Counter ← 0 // You can also add comments at the end of a line

IGCSE Computer Science uses five basic data types:

  • INTEGER: Whole numbers (e.g., 5, -10).
  • REAL: Numbers with fractional parts (e.g., 3.14, -0.5).
  • CHAR: A single character (e.g., 'A', '@').
  • STRING: A sequence of characters (e.g., "Hello World", "").
  • BOOLEAN: Logical values TRUE or FALSE.

Always declare your variables before using them.

DECLARE Counter : INTEGER
DECLARE AverageScore : REAL
DECLARE IsFound : BOOLEAN

Use constants for values that do not change. This makes your code easier to maintain.

CONSTANT Pi ← 3.14159
CONSTANT MaxStudents ← 30

Use the left arrow to assign a value to a variable.

Total ← 0
Name ← "Alex"
  • INPUT: Gets a value from the user.
  • OUTPUT: Displays information on the screen.
OUTPUT "Please enter your name:"
INPUT UserName
OUTPUT "Hello, ", UserName
  • + (Addition)
  • - (Subtraction)
  • * (Multiplication)
  • / (Division)
  • ^ (Power of)
  • DIV(x, y): Integer division (returns the whole number part).
  • MOD(x, y): Modulus (returns the remainder).
Result ← DIV(10, 3) // Result is 3
Remainder ← MOD(10, 3) // Remainder is 1

String handling allows you to manipulate text. Positions in a string generally start at 1.

  • LENGTH(String): Returns the number of characters.
  • LCASE(String): Converts to lower case.
  • UCASE(String): Converts to upper case.
  • SUBSTRING(String, Start, Length): Extracts a part of the string.
MyText ← "Computer Science"
LengthText ← LENGTH(MyText) // returns 16
ShortText ← SUBSTRING(MyText, 1, 8) // returns "Computer"

Used to execute code only if a condition is true.

IF Score >= 50
THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF

Used when you have multiple specific values to check.

CASE OF Grade
'A' : OUTPUT "Excellent"
'B' : OUTPUT "Good"
'C' : OUTPUT "Satisfactory"
OTHERWISE OUTPUT "Improvement needed"
ENDCASE

Use when you know exactly how many times the loop should run.

FOR i ← 1 TO 10
OUTPUT i
NEXT i
// Using a STEP
FOR j ← 10 TO 0 STEP -2
OUTPUT j
NEXT j

Runs while a condition is true. The condition is checked before the loop runs.

WHILE Counter < 10 DO
Counter ← Counter + 1
ENDWHILE

Runs until a condition is true. The loop always runs at least once.

REPEAT
OUTPUT "Enter a positive number:"
INPUT Number
UNTIL Number > 0
DECLARE StudentNames : ARRAY[1:30] OF STRING
StudentNames[1] ← "Ali"
DECLARE Grid : ARRAY[1:3, 1:3] OF CHAR
Grid[2, 3] ← 'X'

A block of code that performs a task but does not return a value.

PROCEDURE WelcomeUser(Name : STRING)
OUTPUT "Welcome, ", Name
ENDPROCEDURE
// Calling a procedure
CALL WelcomeUser("Sam")

A block of code that performs a task and returns a single value.

FUNCTION Square(Number : INTEGER) RETURNS INTEGER
RETURN Number * Number
ENDFUNCTION
// Using a function in an expression
Area ← Square(SideLength)

Files allow you to store data permanently.

  • OPENFILE <filename> FOR <mode> (Modes: READ, WRITE)
  • READFILE <filename>, <variable>
  • WRITEFILE <filename>, <variable>
  • CLOSEFILE <filename>
OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", PlayerScore
CLOSEFILE "Scores.txt"

Common built-in tools:

  • ROUND(Value, Places): Rounds to specified decimal places.
  • RANDOM(): Returns a random number between 0 and 1.