SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
Cambridge IGCSE 0478 · Topic 8 · 8.1b

Selection in
Programming

IF / ELSE IF / ELSE · CASE OF · Logical Operators · Complex Conditions

CSZoneCambridge IGCSE Computer Science 0478
IF...THEN...ELSE

Decision Making in Code

// Simple IF
IF temperature > 30
THEN OUTPUT "Hot day"
ENDIF

// IF with ELSE
IF mark >= 50
THEN OUTPUT "Pass"
ELSE OUTPUT "Fail"
ENDIF

// Chained ELSE IF
IF mark >= 90 THEN OUTPUT "A"
ELSE IF mark >= 70 THEN OUTPUT "B"
ELSE IF mark >= 50 THEN OUTPUT "C"
ELSE OUTPUT "Fail"
ENDIF
ENDIF
ENDIF
Logical Operators

AND, OR, NOT in Conditions

AND: both conditions must be TRUE. e.g. IF age >= 18 AND hasID = TRUE
OR: at least one condition must be TRUE. e.g. IF colour = "red" OR colour = "blue"
NOT: reverses a Boolean result. e.g. IF NOT(found) — equivalent to "if not found"
Comparison operators: = < > <= >= <> (not equal) — used inside IF conditions
CASE OF Statement

Cleaner Multiple Choices

INPUT dayNumber
CASE OF dayNumber
1 : OUTPUT "Monday"
2 : OUTPUT "Tuesday"
3 : OUTPUT "Wednesday"
4 : OUTPUT "Thursday"
5 : OUTPUT "Friday"
6 : OUTPUT "Saturday"
7 : OUTPUT "Sunday"
OTHERWISE : OUTPUT "Invalid day"
ENDCASE
Use CASE OF when comparing a single variable against many fixed values — cleaner than multiple nested IF statements
Exam Practice

Have a go at this question

Cambridge IGCSE 0478 style
Write pseudocode to ask a user for their BMI. Output "Underweight" if below 18.5, "Normal" if 18.5–24.9, "Overweight" if 25–29.9, or "Obese" if 30 or more.
5 marks
INPUT bmi
IF bmi < 18.5
THEN OUTPUT "Underweight"
ELSE IF bmi < 25
THEN OUTPUT "Normal"
ELSE IF bmi < 30
THEN OUTPUT "Overweight"
ELSE OUTPUT "Obese"
ENDIF
ENDIF
ENDIF
Key Takeaways

What to Remember

IF...THEN...ELSE...ENDIF — every IF must close with ENDIF in Cambridge 0478 pseudocode
Logical operators: AND (both true), OR (one true), NOT (inverts) — used to combine conditions
CASE OF...ENDCASE — best for multiple fixed values of one variable; OTHERWISE = catch-all
Comparison operators: = < > <= >= <> — <> means "not equal to"