I need help with this problem. I don't know how to set it up correctly.

Input a list of positive numbers (terminated by 0)into an array, and output the result. Use a subprogram to output the numbers, a function to find the mean, an a subprogram to output the result. I know you have to have a main module, subprogram module, a function module, and a subprogram output module, but I don't know what should be put in any of them and the order they should be put in. Any help would be appreciated.

1 answer

The main should declare and load the list structure (or object), and also a variable to hold the result.

The list structure cannot be fixed length; it needs to grow arbitrarily long.

You'll also need a way to input numbers into the list. Given your modular design, this should also be a subprogram.

The main should then send this list to the function module and retrieve the result.

The list should be sent to a second subprogram for output.

The result should be sent to a third subprogram for output.

Pseudo-code:
main()
declare *aList
declare aMean
call subInputList(&aList)
let aMean = funCalculateMean(&aList)
call subOutputList(&aList)
call subOutputMean(aMean)
end