Course Content
Paper 2 – Problem Solving Approach -Practical
0/102
Past Paper-2 May/June 2025
Past Paper-1 May/June 2025
Download Files
0/1
Olevel : Computer Science 2210 / IGCSE 0478 : Recorded

Reading:

In today’s lesson, we are going to learn an important decision-making structure used in O Level Computer Science 2210 pseudocode: the CASE…OTHERWISE…ENDCASE statement. You already know how to make decisions using IF, THEN, ELSEIF, and ELSE. However, when we have many conditions based on a single variable, using multiple ELSEIFs can make our code long, repetitive, and difficult to read. This is where the CASE structure becomes extremely useful. Think of CASE like a switchboard: you give it one value, and it selects exactly one matching option from a list.

The basic structure of a CASE statement is simple. We write CASE, followed by the variable we want to check. Then, we list the possible values and the actions to perform for each value. At the end, we include the keyword OTHERWISE, which handles any value that does not match the listed options, and then we close the structure using ENDCASE. Because CASE checks only one variable, it is clean, neat, and very easy to trace in exams. This structure helps students avoid long chains of ELSEIF statements and makes the pseudocode easier to read and understand.

Let’s look at a simple example. Suppose we want the user to enter a number from 1 to 4, and based on the number, the program will display a specific message. The pseudocode would look like this: we start by declaring a variable called “choice”, ask the user to enter a number, and store that number in the variable. Then we write:

 
CASE choice OF
1: OUTPUT "YOU SELECTED OPTION 1"
2: OUTPUT "YOU SELECTED OPTION 2"
3: OUTPUT "YOU SELECTED OPTION 3"
4: OUTPUT "YOU SELECTED OPTION 4"
OTHERWISE
OUTPUT "INVALID OPTION"
ENDCASE

This code is extremely easy to follow. If the user enters 1, the program prints “You selected option 1”. If they enter 3, only the message for option 3 runs. But if the user enters something unexpected, like 10, none of the values match, so the program goes to the OTHERWISE part and prints “Invalid option”. This is a perfect example of when CASE should be used: when we have fixed values and each value has a specific output.

The CASE statement is also very useful for text-based options. For example, imagine a grading system where the user enters a grade like A, B, C, or D. Using CASE, the pseudocode becomes short and clear. If the grade is “A”, the program prints “Excellent”. If it is “C”, it prints “Satisfactory”. If the user enters something else, such as “F”, the OTHERWISE part catches the invalid input. This shows that the CASE structure can be used for both numbers and characters, as long as each value is clearly defined.

Before we finish, here are some important exam tips to remember. First, CASE checks one variable only — you cannot write conditions like “grade > 50” inside CASE. Each option must match a single value, such as 1, 2, 3, or “A”. Secondly, the OTHERWISE section is not compulsory, but it is highly recommended because it helps your program handle unexpected input safely. Finally, when using text values, always write them inside quotation marks.

To conclude, the CASE…OTHERWISE…ENDCASE structure is one of the cleanest and simplest ways to make multiple decisions in pseudocode. It is perfect for menu-driven programs, grade checking, weekday selection, and many other tasks you will see in your O Level exam. Practice writing a few CASE statements on your own to build confidence, especially for questions involving menus and fixed choices. Thank you for watching, and see you in the next lesson!

write the given pseudocode in your Notebook.

You cannot copy content of this page