← IGCSE Computer Science Paper 2

CASE OF ... ENDCASE (7a)

Runs the statement beside the first value that matches the variable. An optional OTHERWISE clause, placed last, runs if nothing matches. ENDCASE closes the structure.

Understanding CASE OF ... ENDCASE (7a) in IGCSE Computer Science Paper 2

What it does: Each indented line holds one value ("A" or "B") followed by a colon and its statement. The first match is the one that runs. OTHERWISE comes after the cases 1 and 2, so it only runs when Day is neither 1 nor 2. A CASE structure starts with CASE OF followed by the identifier being tested. THEN is used with IF, not CASE. Every CASE OF is closed with ENDCASE. ENDIF closes an IF statement. OTHERWISE must always be last. Move the 2 : OUTPUT "Stop" line above the OTHERWISE line.

Common mistakes: Each case needs a colon between its value and its statement. Line 3 should be 2 : OUTPUT "Stop". The colon is missing after the value 1. The line should be 1 : OUTPUT "Mon".

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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.

Learning
Duo
Which line correctly starts a CASE structure that tests a variable called Grade?
CASE OF GradeCASE Grade THEN
Matches
CASE OF Choice 1 : OUTPUT "Start" OTHERWISE : OUTPUT "Error" 2 : OUTPUT "Stop" ENDCASE
↓
OTHERWISE is not the last clause. It must come after all the case values, so the 2 case should be placed before it.
Applying
Meanings
Term
CASE OF
Meaning
Runs the statement beside the first value that matches the variable. An optional OTHERWISE clause, placed last, runs if nothing matches. ENDCASE closes the structure.
Practice
CASE OF Grade
Testing
Gaps
Choice
Check Answer
Spots
2 1 : OUTPUT "Start"
3 2 = OUTPUT "Stop"

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Giant Isopod' badge — Patient Builder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line correctly starts a CASE structure that tests a variable called Grade?
A. CASE OF Grade ✓
B. CASE Grade THEN
A CASE structure starts with CASE OF followed by the identifier being tested. THEN is used with IF, not CASE.
2. Where does the OTHERWISE clause go in a CASE structure?
A. First, straight after CASE OF
B. Last, just before ENDCASE ✓
OTHERWISE is checked only when no value matched, so it is written after all the cases and before ENDCASE.
3. What does OTHERWISE do?
A. Runs its statement when no case value matches ✓
B. Runs its statement every time, after the matching case
OTHERWISE is the default. It runs only if none of the listed values matched the variable.
4. Which keyword closes a CASE structure?
A. ENDIF
B. ENDCASE ✓
Every CASE OF is closed with ENDCASE. ENDIF closes an IF statement.
5. Which case line is written correctly in Cambridge pseudocode?
A. 2 : OUTPUT "Two" ✓
B. 2 : OUTPUT "Two" ENDIF
Each case is a value, a colon, then the statement to run. It sits indented two spaces inside the structure and needs no ENDIF.

Match the Pairs

OTHERWISE : OUTPUT "Invalid" → The last clause of a CASE structure. It runs only if no case value matches the variable.
ENDCASE → Closes the CASE OF structure.
Each case has one value, then a colon, then the statement to run when the variable equals that value. → CASE OF Grade "A" : OUTPUT "Top" "B" : OUTPUT "Good" ENDCASE
OTHERWISE is written last, after every case value, and covers all values that do not match. → CASE OF Day 1 : OUTPUT "Mon" 2 : OUTPUT "Tue" OTHERWISE : OUTPUT "Other" ENDCASE
CASE OF Choice 1 : OUTPUT "Start" OTHERWISE : OUTPUT "Error" 2 : OUTPUT "Stop" ENDCASE → OTHERWISE is not the last clause. It must come after all the case values, so the 2 case should be placed before it.
CASE OF Choice 1 : OUTPUT "Start" 2 : OUTPUT "Stop" ENDIF → The structure is closed with ENDIF instead of ENDCASE.

Key Term

CASE OF
Runs the statement beside the first value that matches the variable. An optional OTHERWISE clause, placed last, runs if nothing matches. ENDCASE closes the structure.

Fill in the Blanks

1. CASE OF Choice 1 : OUTPUT "Start" ENDCASE
Hint: Type the two keywords that begin a multi-way selection on a variable.
2. CASE OF Choice 1 : OUTPUT "Start" ENDCASE
Hint: Type the keyword that closes the CASE structure.
3. 2 : OUTPUT "Stop" OTHERWISE : OUTPUT "Invalid" ENDCASE
Hint: Type the keyword for the clause that runs when no value matches. It is always placed last.
4. CASE OF Choice 1 : OUTPUT "Start" ENDCASE
Hint: Type the symbol that separates a case value from the statement beside it.
5. 1 : OUTPUT "One" 2 : OUTPUT "Two" 3 : OUTPUT "Three"
Hint: Type the case value that fits the sequence between the other cases.

Spot the Error

Question 1
A CASE OF Choice
B 1 : OUTPUT "Start"
C 2 = OUTPUT "Stop"
D OTHERWISE OUTPUT "Error"
E ENDCASE
Line C — Each case needs a colon between its value and its statement. Line 3 should be 2 : OUTPUT "Stop".
Question 2
A CASE OF Day
B 1 OUTPUT "Mon"
C 2 : OUTPUT "Tue"
D ENDCASE
Line B — The colon is missing after the value 1. The line should be 1 : OUTPUT "Mon".
Question 3
A CASE OF Mark
B 'A' : OUTPUT "Top"
C 'B' : OUTPUT Good
D OTHERWISE OUTPUT "None"
E ENDCASE
Line C — The text being output is a string, so it needs double quotes. Line 3 should be 'B' : OUTPUT "Good".
Question 4
A CASE OF Size
B 1 : OUTPUT "Small"
C 2 : OUTPUT "Large"
D ENDIF
Line D — A CASE OF structure is closed with ENDCASE, not ENDIF. Line 4 should be ENDCASE.
Question 5
A CASE OF Answer
B Y : OUTPUT "Yes"
C 'N' : OUTPUT "No"
D OTHERWISE OUTPUT "Unknown"
E ENDCASE
Line B — The case value is a CHAR literal, so it needs single quotes. Without them Y looks like a variable. It should be 'Y'.

Student with a class code? Join your class →