IGCSE · Practice questions · Writing and amending algorithms

Build it from parts.

Six original Cambridge-style questions on writing and amending algorithms in pseudocode and flowcharts.

Original questions All questions on this page are original work, written in the Cambridge IGCSE style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Initialise, input, process, output.

01
Write
[5 marks]

Write pseudocode to input the times, in seconds, of 8 runners in a race, then output the fastest (smallest) time and the average time.

  • Initialise Total ← 0 and Fastest to a large value (or the first time). ✓
  • FOR Runner ← 1 TO 8 ... NEXT Runner, with a prompt and INPUT Time inside. ✓
  • Total ← Total + Time inside the loop. ✓
  • IF Time < Fastest THEN Fastest ← Time inside the loop. ✓
  • After the loop: Average ← Total / 8; OUTPUT Fastest and Average. ✓
02
Write
[4 marks]

Write pseudocode that asks the user to guess a secret number stored in Secret. The user keeps guessing until correct. Output "Too high" or "Too low" after each wrong guess, and the number of guesses at the end.

  • Guesses ← 0 before the loop; REPEAT ... UNTIL Guess = Secret. ✓
  • Inside: prompt, INPUT Guess, Guesses ← Guesses + 1. ✓
  • IF Guess > Secret THEN OUTPUT "Too high"; IF Guess < Secret THEN OUTPUT "Too low". ✓
  • After the loop: OUTPUT Guesses. ✓
03
Write
[3 marks]

Draw a flowchart for an algorithm that inputs a temperature and outputs "Hot" if it is above 30, otherwise "Not hot".

  • START and STOP terminators, joined by flow lines. ✓
  • INPUT Temperature in an input/output symbol, then a decision Temperature > 30? with Yes and No exits. ✓
  • Yes leads to OUTPUT "Hot", No leads to OUTPUT "Not hot" (input/output symbols), both then to STOP. ✓
04
Write
[3 marks]

Write the algorithm in Fig. 1 of this lesson in pseudocode.

  • Total ← 0 then INPUT Number. ✓
  • WHILE Number <> -1 DO, with Total ← Total + Number and INPUT Number inside, ENDWHILE. ✓
  • OUTPUT Total after the loop. ✓
05
Write
[3 marks]

Amend the ticket algorithm in this lesson so that it also outputs the largest number of tickets bought by any one customer. State where each new line goes.

  • Before the FOR loop: Largest ← 0. ✓
  • Inside the FOR loop, after validation: IF Tickets > Largest THEN Largest ← Tickets. ✓
  • After the loop: OUTPUT "Largest order: ", Largest. ✓
06
Explain
[2 marks]

A student writes "keep adding the numbers until the user has finished". Explain why this would not gain full marks and rewrite it as pseudocode statements.

  • It is not precise: there is no input statement, rogue value or assignment a computer could follow. ✓
  • e.g. INPUT Number; WHILE Number <> -1 DO; Total ← Total + Number; INPUT Number; ENDWHILE. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.