Asked by Sandy
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.
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.
Answers
Answered by
Graham
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
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
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.