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, ...

Assessment: Computer Science 9210 | Paper 1 Mock 01 | Programming (on-screen) Subject: Computer Science - 9210

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]

Answer Details

(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]

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning