IF ... THEN ... ELSE ... ENDIF (7a)
Gives IF a second path. The THEN statements run when the condition is TRUE and the ELSE statements run when it is FALSE. Exactly one path runs, never both.
Understanding IF ... THEN ... ELSE ... ENDIF (7a) in IGCSE Computer Science Paper 2
What it does: If Answer = 4 is TRUE, Correct is set to TRUE and the ELSE line is skipped. If it is FALSE, Correct ← FALSE runs instead. IF, ELSE and ENDIF start at the same position, and the statements under THEN and ELSE are indented two spaces. There is no ENDELSE. The whole IF statement, including its ELSE part, is closed by one ENDIF. ELSE has no condition of its own. It simply covers the case when the IF condition is FALSE.
Common mistakes: The IF line is missing THEN. It should be IF Age >= 18 THEN so the THEN statements can follow the condition. Assignment uses the arrow ←, not =. The line should be Correct ← TRUE. In pseudocode = is used to compare values.
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 37–46) and word search (Modules 27–46).
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 →