IF…THEN…ENDIF (8.1b)
Runs the indented statements only when the condition is TRUE. If it is FALSE they are skipped. ENDIF closes the selection and lines up with IF.
Understanding IF…THEN…ENDIF (8.1b) in IGCSE Computer Science Paper 2
What it does: If Age is below 18 the OUTPUT "Adult" line is skipped, but OUTPUT "Done" still runs because it comes after ENDIF. Both indented statements belong to the IF, so they either both run (TRUE) or are both skipped (FALSE). 62 is greater than 50, so the condition is TRUE and the statements in the THEN branch run. Cambridge pseudocode closes an IF statement with the single keyword ENDIF. Every IF needs its own ENDIF, written at the same indentation as IF, to show where the selection stops. The condition must be followed by THEN on the same line: IF Score >= 50 THEN.
Common mistakes: The text to output is missing its closing quotation mark. It should be ' OUTPUT "Pass"'. An IF selection is closed with ENDIF, not ENDWHILE. ENDWHILE closes a WHILE loop.
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
IF condition THEN ... ENDIFFill in the Blanks
Spot the Error
Student with a class code? Join your class →