Nested selection with CASE and IF
A CASE clause can hold an IF, and an IF branch can hold a CASE. Close the inner structure first with its own ENDIF or ENDCASE, then close the outer one.
Understanding Nested selection with CASE and IF in IGCSE Computer Science Paper 2
What it does: The IF opens after the CASE, so ENDIF comes before ENDCASE. The last structure opened is the first one closed. Any clause of a CASE can hold other statements, including a complete IF...ENDIF. The IF is inside the clause for 6, so it only runs when that clause is chosen. Every IF needs its own ENDIF. ENDCASE cannot close the inner IF, so the IF is left unfinished.
Common mistakes: A CASE statement must start with CASE OF followed by the variable. The word OF is missing. It should be CASE OF Choice. The outer IF line needs the keyword THEN after its condition. It should be IF Age >= 16 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 389–398) and word search (Modules 379–398).
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
CASE OF ... IF ... ENDIF ... ENDCASEFill in the Blanks
Spot the Error
Student with a class code? Join your class →