[SOLVED] SOLVED:function named "subtotal"

15.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

Write a full program that uses a function named “subtotal” that takes as its arguments the following: (1) An array of floating point values; (2) An integer that tells the number of items in the array. The function should replace the contents of each cell with the sum of the contents of all the cells in the original array from the left end to the current cell in question. Thus, for example, if the array passed to the function looks like this: 0 1 2 3 4 5.5 | 2.0 | 9.5 | 3.2 | 7.0 then when the function returns, the array will have been changed so that it looks like this: 0 1 2 3 4 5.5 | 7.5 | 17.0 | 20.2 | 27.2 Because 5.8 + 2.6 = 8.4 and 5.8 + 2.6 + 9.1 = 17.5 and so on. Note that the content of cell 0 is not changed. The function should not return a value

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.