Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0478

Select a branch with IF and CASE

Choose one path when a condition is true and use CASE when one value selects among alternatives.

Cambridge IGCSE Computer Science 0478 · Programming · 2026–2028 Version 6 · 8.1
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding.

Before you begin

  • Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

What does ELSE handle?

What you will learn

  • Write an IF/ELSE selection
  • Use CASE for distinct alternatives
  • Ensure each valid case has a defined outcome

IF tests a condition

An IF statement runs its THEN branch when its condition is TRUE. ELSE handles the other case, and ENDIF closes the structure.

Conditions should match the requirement precisely, especially at inclusive boundaries. Test one value below, at and above the boundary.

CASE matches one value to a branch

CASE is useful when one variable can match several named or numeric alternatives. Include an OTHERWISE branch when an unexpected value needs a safe response.

Use nested selection only when a decision genuinely depends on an earlier decision. Cambridge limits nested statements to three levels.

Pause and explain

A grade value can be A, B, C or invalid. Which design is clearest?

Put the idea to work

Worked example

Display a message for menu choice 1, 2 or any other value.

Show the worked solution
  1. Read Choice as an integer.
  2. Use CASE to match 1 and 2.
  3. Use OTHERWISE to report an unsupported option.

Answer CASE OF Choice 1 : OUTPUT "Start" 2 : OUTPUT "Help" OTHERWISE OUTPUT "Invalid choice" ENDCASE.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

Write an IF condition that outputs "Adult" for Age >= 18 and "Under 18" otherwise.

Give me a hint

Use one condition and two mutually exclusive branches.

Compare my reasoning
  1. Test Age >= 18.
  2. Output Adult in THEN.
  3. Output Under 18 in ELSE and close with ENDIF.

IF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Under 18" ENDIF.

Look for these in your work

  • Boundary is inclusive
  • Both branches present
2 · Independent

A menu accepts 1 = View, 2 = Edit and 3 = Exit. Describe the branch for a different number.

Give me a hint

Consider the default or OTHERWISE route.

Compare my reasoning
  1. Check the three supported values.
  2. Add OTHERWISE for all unmatched values.
  3. Display an invalid-choice message without performing an action.

Use OTHERWISE to report an invalid choice for any other number.

Look for these in your work

  • Valid choices identified
  • Safe fallback
3 · Transfer

A discount is 20% for purchases over 100, otherwise 10%. Explain what happens for exactly 100 and how to change it if 100 should receive 20%.

Give me a hint

The word over means strictly greater than.

Compare my reasoning
  1. Test whether Price > 100.
  2. At exactly 100, the condition is false, so ELSE applies.
  3. Use Price >= 100 if the threshold itself qualifies.

Exactly 100 currently receives 10%; change > to >= if 100 should receive 20%.

Look for these in your work

  • Boundary traced
  • Correct amendment

Common mistakes

  • Using two independent IF statements when the choices must be exclusive
  • Forgetting ELSE or OTHERWISE for an invalid case
  • Testing overlapping ranges in the wrong order
Recall without your notes

What can you explain now?

Which structure is suited to selecting one of several values of MenuChoice?

Compare with the explanation

CASE

CASE expresses multiple alternatives based on one value.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

When is CASE clearer than a chain of IF statements?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.