Skip to main content

CAMBRIDGE IGCSE · PAPER 2 PRACTICE

You understand the code.
Can you write it?

Start with one small algorithm. Predict what it does, write a change, then test it. This free pseudocode practice guide is built around the skills used in Cambridge 0478.

Try the first exercise

Read every exercise and solution here. No account needed.

Download the printable exercise sheet and answers (PDF, 2 pages)

1. Predict the output before you run it

DECLARE creates an integer variable. The arrow assigns a value. FOR repeats for each number from 1 through 4, including both ends. MOD gives the remainder: a number with remainder 0 when divided by 2 is even. The IF block adds only those even numbers to Total.

DECLARE Total : INTEGER
DECLARE Number : INTEGER
Total ← 0
FOR Number ← 1 TO 4
    IF Number MOD 2 = 0 THEN
        Total ← Total + Number
    ENDIF
NEXT Number
OUTPUT Total

Make columns for Number, the condition and Total. Record the total after each pass. What will OUTPUT Total display?

Check the trace and explanation
Total starts at 0. Values below are recorded after each loop body.
NumberNumber MOD 2 = 0Total
1FALSE0
2TRUE2
3FALSE2
4TRUE6

The output is 6: only 2 and 4 are added. Moving OUTPUT inside the loop would print four totals instead of one.

2. Change one requirement

Rewrite the algorithm to add the odd numbers from 1 through 7. Keep the total at 0 before the loop. Change both the loop limit and the condition, then predict the result.

Check your changes

Use FOR Number ← 1 TO 7 and IF Number MOD 2 = 1 THEN. The output is 16, from 1 + 3 + 5 + 7. Test a limit of 1: it should output 1, so you know the first value is included.

3. Write a small program from a scenario

A club records five scores, each between 0 and 100 inclusive. Write an algorithm that inputs each score, asks again while it is outside that range, adds valid scores and outputs their average.

INPUT reads a value. REPEAT runs its body at least once; UNTIL stops when its condition becomes true. AND requires both comparisons to be true. A REAL variable can hold the fractional average. Assume numeric input for this exercise.

  1. List the inputs, processing and output before writing code.
  2. Write the loop for five valid scores.
  3. Put the range check inside that loop; rejected scores must not increase the total.
  4. Calculate the average only after all five valid scores are recorded.
See one solution and test cases
DECLARE Score, Total, Count : INTEGER
DECLARE Average : REAL
Total ← 0
FOR Count ← 1 TO 5
    REPEAT
        INPUT Score
    UNTIL Score >= 0 AND Score <= 100
    Total ← Total + Score
NEXT Count
Average ← Total / 5
OUTPUT Average
  • Normal: 10, 20, 30, 40, 50 → average 30.
  • Lower boundary: five 0s → average 0.
  • Upper boundary: five 100s → average 100.
  • Rejected inputs: −1 and 101 must each ask again. They must not consume one of the five valid scores.

This is a focused practice exercise, not a complete 15-mark exam question. For longer scenarios, apply the same decomposition and testing steps to each requirement. Practise writing on paper as well as running code.

Run your own algorithm in Pseudocode Studio

CtrlAltRevise brings pseudocode practice, revision notes, worked examples and exam-style questions into one study workspace. Create an account to open the Studio and test your reasoning.

Create an account to practise

This guide is free. Full course access is paid; eligibility and current trial terms are shown during setup. You can also browse the 0478 roadmap before joining.

Using this guide for 0478 or 0984

Check your examination year and syllabus code with your teacher. These exercises practise shared algorithm skills. The platform’s 0984 roadmap currently reuses its verified 0478 content while syllabus equivalence is checked.

Use Cambridge’s official syllabus and published papers as your exam reference. These are original practice exercises, not Cambridge past-paper questions. CtrlAltRevise is independent and not endorsed by Cambridge.

Explore the full IGCSE revision guide