In this guide:
Exam Strategy: IF vs. CASE OF
In the IGCSE 0478 and A-Level 9618 syllabi, examiners expect you to choose the most efficient logical structure. While you *could* use a giant chain of nested IF statements for everything, it's often poor practice.
Score >= 50 AND Score <= 100), or comparing multiple different variables at once.
CASE OF because it proves you know how to write clean, readable code.
Python vs. Pseudocode Conditionals
If you learned Python first, the structure of conditional statements in pseudocode can feel extremely repetitive. You must remember to strictly close every single block you open.
| Concept | 🐍 Python (Wrong for Exams) | 📘 Cambridge Pseudocode (Correct) |
|---|---|---|
| Basic IF Statement | if score == 10: print("Win") |
IF Score = 10 THEN OUTPUT "Win" ENDIF |
| Else If Condition | elif score > 5: print("Close") |
ELSE IF Score > 5 THEN OUTPUT "Close" |
| Multiple Choices | match menu_choice: case 1: play() |
CASE OF MenuChoice 1 : CALL Play() ENDCASE |
1. The IF...THEN...ELSE Statement
The IF statement checks a logical condition. If it is TRUE, one block of code runs. If it is FALSE, the program can optionally run an ELSE block. Every IF statement must be closed explicitly with an ENDIF.
DECLARE ExamScore : INTEGER
ExamScore ← 85
IF ExamScore >= 50 THEN
OUTPUT "You passed the exam!"
ELSE
OUTPUT "You failed. Please retake."
ENDIF
2. Nested IF Statements
You can place an IF statement inside another IF statement to check multiple specific conditions in sequence. Indentation is crucial here so the examiner (and the compiler) can track which ENDIF belongs to which IF.
IF ExamScore >= 90 THEN
OUTPUT "Grade: A*"
IF ExamScore >= 80 THEN
OUTPUT "Grade: A"
ELSE
OUTPUT "Grade: B or lower"
ENDIF
ENDIF
3. The CASE OF Statement
If you have many different specific values to check, nested IF statements become very messy. The CASE OF statement is a much cleaner way to handle multiple choices. Always include an OTHERWISE clause to catch invalid data!
DECLARE MenuChoice : INTEGER
OUTPUT "Enter 1 to Play, 2 to Load, 3 to Quit:"
INPUT MenuChoice
CASE OF MenuChoice
1 : OUTPUT "Starting new game..."
2 : OUTPUT "Loading save file..."
3 : OUTPUT "Exiting game..."
OTHERWISE OUTPUT "Invalid choice."
ENDCASE
Common Syllabus Mistakes
When executing conditionals, watch out for these easily avoidable errors that cost students marks:
❌ Using "==" instead of "=": In Python, you use `==` to check if two values are equal. In standard Cambridge Pseudocode, you strictly use a single `=` sign (e.g., IF X = 10 THEN). Our compiler's Pro Mode will automatically flag `==` as a warning.
❌ Forgetting ENDIF: Unlike Python which uses indentation to know when a statement ends, Pseudocode requires the explicit ENDIF keyword. If you nest 3 IF statements, you must have 3 ENDIF statements at the end.
Interactive Exam Practice
Scenario: Write an algorithm that takes a student's mark (out of 100) as an input. If the mark is 50 or above, output the word "Pass". Otherwise, output "Fail".
Hover or tap the black box to reveal the examiner's solution. Click Run Code to test it instantly!
DECLARE Mark : INTEGER OUTPUT "Enter student mark:" INPUT Mark IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF