← IGCSE Computer Science Paper 2

OTHERWISE in a CASE statement (7c)

The last clause in a CASE statement. It runs when the value matches none of the listed cases, e.g. OTHERWISE OUTPUT "Beep". Without it, nothing happens if there is no match.

Understanding OTHERWISE in a CASE statement (7c) in IGCSE Computer Science Paper 2

What it does: The listed cases come first, then OTHERWISE as the final clause, and ENDCASE closes the statement. OTHERWISE acts as a catch-all, so it can report an error for any value not listed, such as an invalid menu choice. CASE uses OTHERWISE as its catch-all clause. ELSE belongs to IF statements. 7 matches none of 1, 2 or 3, so OTHERWISE runs and outputs "Beep". Without OTHERWISE, a CASE with no matching value does nothing and the program carries on.

Common mistakes: The CASE statement must start with CASE OF so the OTHERWISE clause later has a valid CASE to belong to. The line should be CASE OF Key. A CASE statement uses OTHERWISE for the clause that runs when nothing matches, not ELSE. The line should be OTHERWISE OUTPUT "Beep".

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 166–175) and word search (Modules 166–187).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which clause in a CASE statement runs when none of the listed values match?
OTHERWISEELSE
Matches
CASE Choice OF OTHERWISE OUTPUT "Beep" 1 : OUTPUT "Start" ENDCASE
↓
OTHERWISE is placed first. It must be the last clause, after all the listed cases.
Applying
Meanings
Term
OTHERWISE
Meaning
The last clause in a CASE statement. It runs when the value matches none of the listed cases, e.g. OTHERWISE OUTPUT "Beep". Without it, nothing happens if there is no match.
Practice
INPUT Key
Testing
Gaps
OUTPUT "Beep"
Check Answer
Spots
1INPUT Key
2CASE Key

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

The 'Arctic Fox' badge — Tundra Tracker, 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 clause in a CASE statement runs when none of the listed values match?
A. ELSE
B. OTHERWISE ✓
CASE uses OTHERWISE as its catch-all clause. ELSE belongs to IF statements.
2. Where must OTHERWISE be placed in a CASE statement?
A. Last, just before ENDCASE ✓
B. First, straight after CASE OF
OTHERWISE is the last clause. It only runs if no earlier case matched.
3. Choice ← 7. The CASE has cases 1, 2 and 3 and then OTHERWISE OUTPUT "Beep". What is output?
A. Nothing is output
B. Beep ✓
7 matches none of 1, 2 or 3, so OTHERWISE runs and outputs "Beep".
4. Choice ← 7. The CASE has cases 1, 2 and 3 but NO OTHERWISE clause. What happens?
A. Nothing happens ✓
B. The program shows an error message automatically
Without OTHERWISE, a CASE with no matching value does nothing and the program carries on.
5. Choice ← 2. The CASE has 1, 2, 3 and OTHERWISE OUTPUT "Beep". Does the OTHERWISE line run?
A. No, because case 2 matched ✓
B. Yes, OTHERWISE always runs at the end
OTHERWISE only runs when no listed case matches. Case 2 matched, so it is skipped.

Match the Pairs

OTHERWISE OUTPUT "Beep" → If the value matches none of the listed cases, output Beep
CASE Choice OF 1 : OUTPUT "Start" 2 : OUTPUT "Stop" ENDCASE → A CASE with no OTHERWISE: if Choice is 3, nothing happens
OTHERWISE must be the last clause in the CASE statement, just before ENDCASE → CASE Choice OF 1 : OUTPUT "Start" OTHERWISE OUTPUT "Beep" ENDCASE
OTHERWISE catches every value that is not one of the listed cases, such as an invalid menu choice → OTHERWISE OUTPUT "Invalid choice"
CASE Choice OF OTHERWISE OUTPUT "Beep" 1 : OUTPUT "Start" ENDCASE → OTHERWISE is placed first. It must be the last clause, after all the listed cases.
CASE Choice OF 1 : OUTPUT "Start" 2 : OUTPUT "Stop" ENDCASE // expects "Beep" for other values → There is no OTHERWISE, so no "Beep" is output when Choice is not 1 or 2. The CASE does nothing.

Key Term

OTHERWISE
The last clause in a CASE statement. It runs when the value matches none of the listed cases, e.g. OTHERWISE OUTPUT "Beep". Without it, nothing happens if there is no match.

Fill in the Blanks

1. "Y" : OUTPUT "Yes" OTHERWISE OUTPUT "Beep" ENDCASE
Hint: Type the keyword that starts the clause which runs when no listed value matches.
2. 2 : OUTPUT "Stop" OTHERWISE OUTPUT "Beep" ENDCASE
Hint: Type the keyword that closes the CASE statement after the OTHERWISE clause.
3. 1 : OUTPUT "Go" OTHERWISE OUTPUT "Beep" ENDCASE
Hint: Type the keyword that displays the text when the OTHERWISE clause runs.
4. CASE OF Key 1 : OUTPUT "Go" OTHERWISE OUTPUT "Beep"
Hint: Type the word that follows CASE and comes before the variable being tested.
5. "N" : OUTPUT "North" OTHERWISE OUTPUT "Beep" ENDCASE
Hint: Type the clause that must be the last one, covering every value not listed above it.

Spot the Error

Question 1
A INPUT Key
B CASE Key
C 1 : OUTPUT "Go"
D OTHERWISE OUTPUT "Beep"
E ENDCASE
Line B — The CASE statement must start with CASE OF so the OTHERWISE clause later has a valid CASE to belong to. The line should be CASE OF Key.
Question 2
A CASE OF Colour
B "R" : OUTPUT "Red"
C "G" : OUTPUT "Green"
D ELSE OUTPUT "Beep"
E ENDCASE
Line D — A CASE statement uses OTHERWISE for the clause that runs when nothing matches, not ELSE. The line should be OTHERWISE OUTPUT "Beep".
Question 3
A CASE OF Key
B OTHERWISE OUTPUT "Beep"
C 2 : OUTPUT "Stop"
D OTHERWISE OUTPUT "Beep"
E ENDCASE
Line B — OTHERWISE must be the last case in the CASE statement. Putting it here, before the other cases, is wrong. Line 2 should be the case 1 : OUTPUT "Go".
Question 4
A CASE OF Score
B 10 : OUTPUT "Full marks"
C OTHERWISE "Beep"
D ENDCASE
Line C — The OTHERWISE clause needs a statement to run. OUTPUT is missing, so it should be OTHERWISE OUTPUT "Beep".
Question 5
A CASE Mode OF
B "R" : OUTPUT "Run"
C OTHERWISE OUTPUT "Beep"
D ENDCASE
Line A — The words are in the wrong order. The correct start is CASE OF Mode, before the cases and the OTHERWISE clause.

Student with a class code? Join your class →