Nested IF statements (7c)
An IF statement placed inside the THEN or ELSE part of another IF, with its own ENDIF. The inner condition is only checked when the outer one sends the program into that part.
Understanding Nested IF statements (7c) in IGCSE Computer Science Paper 2
What it does: There are two IFs and two ENDIFs. The inner ENDIF closes the inner IF first, then the outer ENDIF closes the outer IF. The second IF is inside the ELSE part, so Temp > 15 is only checked when Temp > 30 is FALSE. Nested means one IF is inside another. Two IFs in a row are just a sequence of selections. Paper 2 uses nested IFs with at most three levels.
Common mistakes: The inner IF must be closed with its own ENDIF. ENDWHILE belongs to a WHILE loop. Line 4 should be ENDIF. The inner IF needs a comparison, not an assignment. ← stores a value, so it should be IF Temp > 40 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
nested IFFill in the Blanks
Spot the Error
Student with a class code? Join your class →