logo

Pearson Edexcel GCSE (9-1) Computer Science practice

A program needs to calculate the average of ten numbers entered by a user. Describe, using pseudocode, an algorithm that achieves this. Your algorithm should include input, processing, output, and a suitable form of repetition. [6 marks]

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

exam_style

Style

Topic

Algorithms

Exam-style question

Try this first

A program needs to calculate the average of ten numbers entered by a user. Describe, using pseudocode, an algorithm that achieves this. Your algorithm should include input, processing, output, and a suitable form of repetition. [6 marks].

Answer and explanation

Concise answer

```pseudocode FUNCTION CalculateAverageOfTen() SET total = 0 FOR counter FROM 1 TO 10 OUTPUT "Enter a number: " INPUT number SET total = total + number ENDFOR SET average = total / 10 OUTPUT "The average is: " + average ENDFUNCTION ```

Why this is correct

1 mark for correct initialisation of `total`. 1 mark for using a count-controlled loop (e.g., FOR loop) that iterates 10 times. 1 mark for correctly getting input inside the loop. 1 mark for correctly accumulating the sum within the loop. 1 mark for calculating the average correctly after the loop. 1 mark for correctly outputting the average.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

Flashcard 1 of 6

Press Space to flip, arrows to move

Related practice questions