← IGCSE Computer Science Paper 2

CASE OF…ENDCASE (8.1b)

Compares one variable (here Choice) with a list of values, runs the statement beside the matching value, and is closed by ENDCASE.

Understanding CASE OF…ENDCASE (8.1b) in IGCSE Computer Science Paper 2

What it does: The layout is value : statement, so the statement beside the matching value is the one that runs. CASE works on INTEGER or CHAR variables. Each CHAR value is in single quotes and is on its own line, and the statement is closed by ENDCASE. A CASE statement starts with CASE OF followed by the identifier. THEN belongs to IF statements, not CASE. The statement must end with ENDCASE. Ending it with ENDIF is a syntax error.

Common mistakes: The CASE line is missing the keyword OF. It should be CASE OF Choice. A CASE clause needs a colon between the value and the statement, not an equals sign. It should be 'B' : OUTPUT "Good".

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
Which line correctly starts a CASE statement that tests the variable Choice?
CASE OF ChoiceCASE Choice THEN
Matches
CASE OF Choice 1 : OUTPUT "Start" 2 : OUTPUT "Quit"
↓
ENDCASE is missing, so the CASE statement is never closed. Add ENDCASE after the last value.
Applying
Meanings
Term
CASE OF Choice
Meaning
Compares one variable (here Choice) with a list of values, runs the statement beside the matching value, and is closed by ENDCASE.
Practice
CASE OF Choice
Testing
Gaps
OF Choice
Check Answer
Spots
1CASE Choice
2 1 : OUTPUT "Play"

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

The 'Ostrich' badge — Full Sprint, 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 statement that tests the variable Choice?
A. CASE Choice THEN
B. CASE OF Choice ✓
A CASE statement starts with CASE OF followed by the identifier. THEN belongs to IF statements, not CASE.
2. Which keyword closes a CASE statement?
A. ENDCASE ✓
B. ENDIF
Every CASE OF is closed by ENDCASE. ENDIF closes an IF statement.
3. Which is the correct way to write one value and its statement inside a CASE?
A. 1 : OUTPUT "Start" ✓
B. 1 THEN OUTPUT "Start"
Each clause is written as value : statement, with a colon between them. THEN is not used in CASE.
4. How should the values be laid out inside a CASE statement?
A. One value per line, each with its own statement ✓
B. All the values on one line, separated by commas
Each value goes on its own line with the statement that runs when it matches. This keeps the CASE easy to read.
5. What does CASE OF Choice do when Choice has the value 2?
A. Runs every statement in the CASE one after another
B. Runs the statement beside the value 2 ✓
CASE compares the variable with the list of values and runs only the statement beside the matching value.

Match the Pairs

CASE OF Choice → Starts a CASE statement that compares the variable Choice with a list of values
ENDCASE → Closes the CASE statement after the last value has been listed
Each value is written with a colon, then the statement that runs when the variable matches that value → 1 : OUTPUT "Start"
A CASE statement can test a CHAR variable, with each CHAR value written one per line → CASE OF Grade 'A' : OUTPUT "Top" 'B' : OUTPUT "Good" ENDCASE
CASE OF Choice 1 : OUTPUT "Start" 2 : OUTPUT "Quit" → ENDCASE is missing, so the CASE statement is never closed. Add ENDCASE after the last value.
CASE OF Choice 1 OUTPUT "Start" 2 OUTPUT "Quit" ENDCASE → The colon is missing between each value and its statement. It should be 1 : OUTPUT "Start".

Key Term

CASE OF Choice
Compares one variable (here Choice) with a list of values, runs the statement beside the matching value, and is closed by ENDCASE.

Fill in the Blanks

1. CASE OF Choice 1 : OUTPUT "Start" ENDCASE
Hint: Type the keyword that begins a statement comparing one variable with a list of values.
2. CASE OF Choice 1 : OUTPUT "Start" ENDCASE
Hint: Type the name of the variable whose value is being compared with the list.
3. CASE OF Choice 2 : OUTPUT "Quit" ENDCASE
Hint: Type the keyword that closes the whole selection structure.
4. CASE OF Grade 'A' : OUTPUT "Top mark" ENDCASE
Hint: Type the symbol that separates a value from the statement beside it.
5. CASE OF Choice 2 : OUTPUT "Quit" ENDCASE
Hint: Type the keyword that shows a message and runs when the value matches.

Spot the Error

Question 1
A CASE Choice
B 1 : OUTPUT "Play"
C 2 : OUTPUT "Quit"
D ENDCASE
Line A — The CASE line is missing the keyword OF. It should be CASE OF Choice.
Question 2
A INPUT Grade
B CASE OF Grade
C 'A' : OUTPUT "Top"
D 'B' = OUTPUT "Good"
E ENDCASE
Line D — A CASE clause needs a colon between the value and the statement, not an equals sign. It should be 'B' : OUTPUT "Good".
Question 3
A CASE OF Day
B 1 : OUTPUT "Mon"
C 2 : OUTPUT "Tue
D 3 : OUTPUT "Wed"
E ENDCASE
Line C — The text in the OUTPUT statement is missing its closing quote. It should be OUTPUT "Tue".
Question 4
A DECLARE Choice : INTEGER
B CASE OF Choice
C 1 : OUTPUT "Add"
D "2" : OUTPUT "Delete"
E ENDCASE
Line D — Choice is an INTEGER, so each value must be a whole number without quotes. It should be 2 : OUTPUT "Delete".
Question 5
A INPUT Key
B CASE IF Key
C 'Y' : OUTPUT "Yes"
D 'N' : OUTPUT "No"
E ENDCASE
Line B — A CASE statement starts with CASE OF, not CASE IF. IF belongs to selection with a condition. It should be CASE OF Key.

Student with a class code? Join your class →