IF…THEN…ENDIF (7d)
Runs the indented lines between THEN and ENDIF only when the condition is TRUE. If it is FALSE, those lines are skipped. Every IF must be closed with its own ENDIF.
Understanding IF…THEN…ENDIF (7d) in IGCSE Computer Science Paper 2
What it does: The OUTPUT line is indented under THEN, showing it belongs to the IF and runs only when Age >= 18 is TRUE. Count is 0, so Count > 5 is FALSE. OUTPUT "Big" is skipped and the program carries on to OUTPUT "Done" after ENDIF. Every IF ... THEN must be closed with its own ENDIF. Plain END is not used for IF. The second version has no ENDIF, so the IF is never closed. Indenting the THEN lines makes it clear which statements are controlled by the condition. Count = 0 is TRUE, so the assignment inside the IF runs and Count becomes 1.
Common mistakes: The IF line is missing the keyword THEN. The condition must be followed by THEN: IF score >= 50 THEN. The ← symbol assigns a value. A condition needs a comparison operator, so it should be IF temp = 30 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 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
IF condition THEN ... ENDIFFill in the Blanks
Spot the Error
Student with a class code? Join your class →