Choosing between IF and CASE
Use CASE OF when one variable is matched against fixed values, like a menu choice. Use IF when you test conditions with <, > or AND/OR, like age or score tests.
Understanding Choosing between IF and CASE in IGCSE Computer Science Paper 2
What it does: Each CASE clause becomes an IF Choice = value test, with the next test placed inside ELSE. This works but is longer and harder to read than CASE. One variable matched against fixed values like menu options is what CASE is designed for. A test using a relational operator such as >= suits IF. CASE matches values or ranges, not comparison conditions. CASE looks at a single variable. Conditions that combine different variables with AND/OR need IF.
Common mistakes: A menu choice is a good fit for CASE, but the keyword OF is missing. The line should be CASE OF Choice. OTHERWISE belongs in a CASE statement. An IF statement uses ELSE for the alternative, so the line should be ELSE OUTPUT "Pass".
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
CASE OFFill in the Blanks
Spot the Error
Student with a class code? Join your class →