Nested IF statements (7a)
An IF statement written inside the THEN or ELSE part of another IF. It only runs when the outer condition leads to it, and each IF needs its own ENDIF.
Understanding Nested IF statements (7a) in IGCSE Computer Science Paper 2
What it does: The second IF sits inside the ELSE part, so it only runs when Age >= 18 is false. One IF gives two outcomes. A nested IF in the ELSE splits it again to give three outcomes, and each level is indented two more spaces. Every IF needs its own ENDIF. The inner ENDIF closes the inner IF and the outer ENDIF closes the outer IF. The outer condition 40 >= 50 is False, so the program skips the THEN part and never reaches the inner IF. Add a second ENDIF at the end to close the outer IF. Two IF statements need two ENDIF lines.
Common mistakes: An IF statement must use THEN after its condition, not DO. The outer IF should read IF Mark >= 50 THEN. The ← symbol is for assignment. A condition compares values with =, so the nested IF should read IF HasPermission = TRUE 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 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
nested IFFill in the Blanks
Spot the Error
Student with a class code? Join your class →