Question 1 Report
A wildlife rescue centre records the mass of each hedgehog before release. The technician uses a program with a variable called totalMass. For each animal, the program adds the new mass to this total and increases numberReleased by one. At the end, a subroutine calculates the mean mass. The technician wants the program to be structured so that the calculation can also be used for badgers in a separate test program.
(a) Explain why totalMass should be initialised to 0 before the loop starts. [2]
(b) When the mean-mass subroutine is called, state one input parameter it needs. [1]
(a) totalMass is an accumulator, so it needs the known starting value 0 before masses are added. [1] This prevents an old or undefined value from being included in the final total. [1]
(b) The mean-mass subroutine needs totalMass as an input parameter; it may also need numberReleased to calculate the mean. [1]
Everything you need to excel in your exams