Hello all i am wondering what would be the best way to have a user input up to but not required to 20 test scores, average them, and display the average of all the test scores.
I was thinking I could have a function that uses an array to hold the 20 test scores, calculate them, display the result and return to the main function.
Is that possible and is it the most efficient way to write it.
I will update with the code if anyone is interested. Feel free to upload your version as well once there are some answers.
|I was thinking I could have a function that uses an array to hold the 20 test scores, calculate them, display the result and return to the main function.|
An alternative it to have a function read the user input and store the values in a standard collection (a vector, for example).
You could then write a function that takes the average of your collected values. It only does the calculation on a parameter, it doesn't store anything.
main would look something like:
values = get_values
average = get_average( values )
Last edited on
Well thank all of you for the input i was away for a couple days but, I will post my code once it is written. thank you all for your help