IF ... THEN ... ENDIF (7c)
Runs the statements between THEN and ENDIF only when the condition is TRUE. If it is FALSE, they are skipped. Every IF must be closed with ENDIF, e.g. IF Score > 50 THEN OUTPUT "Pass" ENDIF.
Understanding IF ... THEN ... ENDIF (7c) in IGCSE Computer Science Paper 2
What it does: OUTPUT "Can apply" only runs when Age >= 16 is TRUE. If Age is 15 it is skipped and the program carries on after ENDIF. The IF line is matched by an ENDIF at the end, so the structure is complete and correct. Every IF must be closed with ENDIF. Without it the statement is incomplete. 40 > 50 is FALSE, so the statements between THEN and ENDIF are skipped. > means strictly greater than. 50 is not greater than 50, so the condition is FALSE. An IF statement uses THEN after the condition. DO belongs to WHILE loops. The IF line should read IF Score > 50 THEN. THEN separates the condition from the statements that run when it is TRUE.
Common mistakes: Text to be displayed must be written as a string literal in double quotes. Without quotes, Pass looks like a variable. It should be OUTPUT "Pass". The condition must be followed by THEN, which introduces the statements that run when the condition is TRUE. It should be IF Score > 50 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 156–165) and word search (Modules 146–165).
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 ... THEN ... ENDIFFill in the Blanks
Spot the Error
Student with a class code? Join your class →