IF…THEN…ELSE…ENDIF (8.1b)
Adds a second branch that runs when the IF condition is FALSE, so exactly one of the two branches runs. ELSE has no condition of its own and lines up with its IF.
Understanding IF…THEN…ELSE…ENDIF (8.1b) in IGCSE Computer Science Paper 2
What it does: IF, ELSE and ENDIF start in the same column, which shows the two branches belong to one selection. Score is 30, so Score >= 50 is FALSE. The THEN branch is skipped and only Fail is output. ELSE has no condition of its own. The condition belongs to the IF. There are two branches but one result. Either the THEN branch or the ELSE branch runs, never both. ELSE lines up with IF (and ENDIF), so the structure is easy to read. Only the statements inside each branch are indented. The condition goes after IF. The ELSE branch holds the action for when the condition is FALSE.
Common mistakes: The IF line is missing THEN. It should be IF mark >= 50 THEN so the true branch can start. The condition is the wrong way round. High scores would output Fail and low scores Pass. It should be IF score < 40 THEN.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 369–378) and word search (Modules 358–378).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
ELSEFill in the Blanks
Spot the Error
Student with a class code? Join your class →