A procedure TwoParts() will input a sequence of real values, one at a time. The procedure will: • process the sequence in two parts • form a first total by adding the values until the first zero • form a second total by adding the values after the first zero until the second zero • output the average of the two totals, together with a suitable message. Values input in the first part are totalled using global variable TotalA and those input in the second part are totalled using global variable TotalB.
- (a)Write pseudocode for the procedure TwoParts().[6]
- (b)(i)Identify a suitable data structure that could be used to store the different total values.[2]
- (b)(ii)Describe three benefits of using the data structure given in part (b)(i).[3]
Mark scheme
Marking points from the official mark scheme (May/June 2024). The mark or mark type is shown in brackets.
- [1] (a) Procedure heading and ending
- [1] (a) Declare all local variables
- [1] (a) Initialise TotalA and TotalB
- [1] (a) First conditional loop until zero entered, summing TotalA // Loop until both parts (sequences) have been entered
- [1] (a) Second conditional loop until zero entered, summing TotalB // Loop summing appropriate Totals
- [1] (a) Calculation of average and output with a message // Calculation of the average for the values making up the two totals and both output with a suitable message
- [1] (b)(i) (1D) array
- [1] (b)(i) of 20 reals
- [1] (b)(ii) (Multiple instances referenced via a single identifier so) fewer identifiers needed
- [1] (b)(ii) Easier to process / search / organise / access the data // Values may be accessed via a loop-controlled variable /an index //An array / data can be iterated through
- [1] (b)(ii) Makes the program/algorithm easier to write / design / understand / maintain / modify // Simplifies the program // Easier to debug / test
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →