Several alternatives with IF inside ELSE
A nested IF placed inside ELSE to choose between 3+ alternatives. Conditions are tested in order, only one branch runs, and every IF needs its own ENDIF.
Understanding Several alternatives with IF inside ELSE in IGCSE Computer Science Paper 2
What it does: The highest boundary (80) is tested first, then the next one down (50). Testing 50 first would give a mark of 85 a B. The outer IF and the nested IF each have a matching ENDIF. The inner ENDIF comes first, then the outer one. An IF can only have one ELSE. To get a third alternative, put a second IF inside the ELSE branch. Each IF needs its own ENDIF, so two IFs need two ENDIFs. The program does not look for the best match. It runs the first branch that is true, so the order of the conditions matters.
Common mistakes: The inner IF must be closed with its own ENDIF. ENDCASE belongs to a CASE statement. Line 4 should be ' ENDIF'. Conditions are tested in order, so the highest boundary must come first. Testing 60 first gives A to every mark from 60 up, and the B branch can never run. Line 1 should test Pts >= 80.
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
ELSE IFFill in the Blanks
Spot the Error
Student with a class code? Join your class →