IF…THEN…ELSE…ENDIF (7d)
Starts the lines that run when the IF condition is FALSE. Exactly one branch runs: THEN or ELSE, never both. ELSE has no condition of its own.
Understanding IF…THEN…ELSE…ENDIF (7d) in IGCSE Computer Science Paper 2
What it does: The ELSE line is written on its own with no test after it. It runs automatically whenever Age >= 16 is FALSE. A number is either even or odd, so the condition is TRUE or FALSE. This means one of the two outputs always happens and the other is skipped. ELSE has no condition of its own. It just means 'otherwise'. Only IF (and ELSE IF) test a condition. There is no ENDELSE. The ELSE lines sit inside the IF structure, and a single ENDIF closes it.
Common mistakes: ELSE has no condition of its own. It runs automatically when the IF condition is FALSE. The line should be just ELSE. The THEN branch runs when Mark >= 50 is TRUE, so it should output "Pass". Outputting "Fail" there gives the wrong message. The line should be OUTPUT "Pass".
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 265–274) and word search (Modules 254–274).
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 →