Skip to content

Course home

Algorithms

Algorithms

EasyMedium
123456789101112131415161718
Question 14

Figure 1 shows an algorithm Chloe has written using pseudocode to calculate the mean of a series of temperature readings.

Chloe uses the input sequence 10, 20, 30, -99 to test her algorithm, where -99 is the sentinel value used to stop input.

Figure 1

1  SET total TO 0
2  SET temp TO 0
3  SET count TO 0
4  WHILE temp <> -99 DO
5      SEND 'Enter temperature (or -99 to stop):' TO DISPLAY
6      RECEIVE temp FROM (INTEGER) KEYBOARD
7      SET total TO total + temp
8      SET count TO count + 1
9  END WHILE
10 SET mean TO total / count
11 SEND 'The mean temperature is ' & mean TO DISPLAY

Test Results Table

Expected resultActual result
The mean temperature is 20The mean temperature is -9.75

Explain why the Actual result is not the same as the Expected result.

[2]
Markscheme

Algorithms Questions

  1. IGCSE
  2. /Computer Science
  3. /Algorithms

45 exam-style questions on Edexcel IGCSE Computer Science Algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank