← All Paper 2 problems·All lessons
Paper 2 scenario practice

Top 3 scores from a competition

The scenario
A school programming competition records the scores of 10 finalists in an array Scores[1:10]. The organisers want a program that: 1. Has the 10 scores already loaded in the array. (You do NOT need to load them — assume they are present.) 2. SORTS the array in DESCENDING order, so the highest score is at position 1. 3. OUTPUTS the top 3 scores (positions 1, 2, and 3 after sorting), with their rank. For example: '1st: 91', '2nd: 88', '3rd: 78'. Use a BUBBLE SORT (Cambridge's named algorithm) for the sort step. Write a program in pseudocode (or a high-level language of your choice). Marks will be awarded for correct sort logic, output formatting, and clear program structure.
Lessons that prepare for this: Lesson 19 — Pseudocode and flowcharts · Lesson 20 — Sorting algorithms · Lesson 24 — Arrays
Marking scheme — total 15 marks
Cambridge IGCSE 0478 Paper 2
  • 2
    Declare variables: DECLARE the loop counters and the temp variable used for swapping. Sensible identifiers (i, j, temp).
  • 2
    Outer sort loop: FOR i ← 1 TO n-1 (where n = 10). Each pass through this loop bubbles the next smallest value to the end.
  • 4
    Inner compare-and-swap loop: FOR j ← 1 TO n-i. For each adjacent pair, IF Scores[j] < Scores[j+1] THEN swap. The swap uses a temp variable: temp ← a; a ← b; b ← temp. Direction matters — for DESCENDING sort, swap when current is less than next.
  • 4
    Output top 3: After sorting, output the values at positions 1, 2, 3 with their rank labels ('1st:', '2nd:', '3rd:'). The rank labels must match the position.
  • 3
    Program structure and naming: Code reads top-to-bottom; FOR/NEXT properly paired; IF/ENDIF visible; identifiers like 'temp' and 'Scores' clearer than 't' and 'arr'.
Hints — reveal one at a time, only if stuck
Your pseudocode workspace
1 line