← IGCSE Computer Science Paper 2

OTHERWISE in a CASE statement (8.1b)

The last clause of a CASE statement. It runs when the variable matches none of the listed values, e.g. OTHERWISE : OUTPUT "Invalid choice". Without it, nothing happens if no value matches.

Understanding OTHERWISE in a CASE statement (8.1b) in IGCSE Computer Science Paper 2

What it does: The OTHERWISE clause comes after every listed value and directly before ENDCASE. This line is the catch-all that reports an invalid choice when no listed value matches. OTHERWISE comes last. It only runs when none of the values above it matched. OTHERWISE is followed by a colon and then the statement to run, just like the other CASE clauses. It does not use ELSE.

Common mistakes: Each CASE clause needs a colon between the value and the statement. It should be 1 : OUTPUT "Start". A CASE statement starts with CASE OF followed by the variable. OF is missing; it should be CASE OF Menu. Without it, the OTHERWISE clause has no valid CASE to belong to.

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 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.

Learning
Duo
Where does OTHERWISE go in a CASE statement?
As the first clause, before the listed valuesAs the last clause, after all the listed values
Matches
CASE OF Choice OTHERWISE : OUTPUT "Invalid choice" 1 : OUTPUT "Start" ENDCASE
↓
OTHERWISE is placed before the listed value. It must be the last clause, so move it below 1 : OUTPUT "Start".
Applying
Meanings
Term
OTHERWISE
Meaning
The last clause of a CASE statement. It runs when the variable matches none of the listed values, e.g. OTHERWISE : OUTPUT "Invalid choice". Without it, nothing happens if no value matches.
Practice
CASE OF Choice
Testing
Gaps
: OUTPUT "Invalid choice"
Check Answer
Spots
1CASE OF Choice
2 1 OUTPUT "Start"

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

The 'Roadrunner' badge — Streak Runner, 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. Where does OTHERWISE go in a CASE statement?
A. As the last clause, after all the listed values ✓
B. As the first clause, before the listed values
OTHERWISE comes last. It only runs when none of the values above it matched.
2. When does the OTHERWISE clause run?
A. Every time the CASE statement runs
B. When the variable matches none of the listed values ✓
OTHERWISE is a catch-all. It is skipped if one of the listed values matches.
3. Choice is 7 and the CASE only lists 1, 2 and 3, with no OTHERWISE. What happens?
A. Nothing happens, no clause runs ✓
B. The program stops with an error message
A CASE without OTHERWISE does nothing when no value matches. The program carries on with the next statement.
4. Which line is the correct way to write an OTHERWISE clause?
A. OTHERWISE OUTPUT "Invalid choice" ELSE
B. OTHERWISE : OUTPUT "Invalid choice" ✓
OTHERWISE is followed by a colon and then the statement to run, just like the other CASE clauses. It does not use ELSE.
5. Choice is 2 and the CASE has 2 : OUTPUT "Option 2" and OTHERWISE : OUTPUT "Invalid choice". What is output?
A. Option 2 ✓
B. Option 2 and Invalid choice
Only one clause runs. Since 2 matched, OTHERWISE is skipped.

Match the Pairs

OTHERWISE : OUTPUT "Invalid choice" → Runs and displays an error message when the CASE variable matches none of the listed values
CASE OF Choice 1 : OUTPUT "Start" 2 : OUTPUT "Quit" ENDCASE → A CASE with no OTHERWISE, so nothing happens if Choice is 3
OTHERWISE must be the last clause, placed after all the listed values and just before ENDCASE → CASE OF Grade 'A' : OUTPUT "Top" 'B' : OUTPUT "Good" OTHERWISE : OUTPUT "Try again" ENDCASE
Use OTHERWISE to catch invalid menu choices and tell the user → OTHERWISE : OUTPUT "Invalid choice"
CASE OF Choice OTHERWISE : OUTPUT "Invalid choice" 1 : OUTPUT "Start" ENDCASE → OTHERWISE is placed before the listed value. It must be the last clause, so move it below 1 : OUTPUT "Start".
OTHERWISE OUTPUT "Invalid choice" → The colon is missing after OTHERWISE. It should be OTHERWISE : OUTPUT "Invalid choice".

Key Term

OTHERWISE
The last clause of a CASE statement. It runs when the variable matches none of the listed values, e.g. OTHERWISE : OUTPUT "Invalid choice". Without it, nothing happens if no value matches.

Fill in the Blanks

1. CASE OF Choice 1 : OUTPUT "Play" OTHERWISE : OUTPUT "Invalid choice"
Hint: Type the last clause that runs when none of the listed values match.
2. 1 : OUTPUT "Play" OTHERWISE : OUTPUT "Invalid choice" ENDCASE
Hint: Type the keyword that displays a message on the screen.
3. 2 : OUTPUT "Quit" OTHERWISE : OUTPUT "Invalid choice" ENDCASE
Hint: Type the keyword that closes the CASE statement after the last clause.
4. CASE OF Menu OTHERWISE : OUTPUT "Invalid choice" ENDCASE
Hint: Type the keyword that links CASE to the variable being tested.
5. 3 : OUTPUT "Exit" OTHERWISE : OUTPUT "Invalid choice" ENDCASE
Hint: Type the clause that is always written last and catches every other value.

Spot the Error

Question 1
A CASE OF Choice
B 1 OUTPUT "Start"
C OTHERWISE : OUTPUT "Error"
D ENDCASE
Line B — Each CASE clause needs a colon between the value and the statement. It should be 1 : OUTPUT "Start".
Question 2
A CASE Menu
B 1 : OUTPUT "Play"
C 2 : OUTPUT "Quit"
D OTHERWISE : OUTPUT "Error"
E ENDCASE
Line A — A CASE statement starts with CASE OF followed by the variable. OF is missing; it should be CASE OF Menu. Without it, the OTHERWISE clause has no valid CASE to belong to.
Question 3
A CASE OF Day
B 1 : OUTPUT "Mon"
C 2 : OUTPUT "Tue"
D OTHERWISE OUTPUT "Error"
E ENDCASE
Line D — OTHERWISE must be followed by a colon, just like the value clauses. It should be OTHERWISE : OUTPUT "Error".
Question 4
A CASE Grade OF
B "A" : OUTPUT "Top"
C "B" : OUTPUT "Good"
D OTHERWISE : OUTPUT "Error"
E ENDCASE
Line A — The keywords come first, then the variable: CASE OF Grade. The words are in the wrong order. Then OTHERWISE can catch any grade that is not A or B.
Question 5
A CASE OF Choice
B 1 : OUTPUT "Start"
C ELSE : OUTPUT "Error"
D ENDCASE
Line C — ELSE belongs to IF statements. The last CASE clause that runs when no value matches is OTHERWISE. It should be OTHERWISE : OUTPUT "Error".

Student with a class code? Join your class →