Thursday, July 9, 2009

How can I find the minimum, maximum, and average numbers of a thousand integer array in c++? (using functions)

I have an assignment in my comp sci c++ class and i cant figure out how to find the min, max, or average of 1000 integers in an array. I completed the rest of the program but I'm really stuck on this part of it.

How can I find the minimum, maximum, and average numbers of a thousand integer array in c++? (using functions)
graphing calculator will solve it in like a second
Reply:Define the min, max, and sum of the array as the value of the first element.


Iterate through the rest of the array, replacing the then-current min with any smaller value you find, replacing the then-current max with any larger value you find, and adding each element's value to the sum. When you've finished iterating, you'll have the min and the max, and the average will be the sum divided by the number of elements.





Since this is schoolwork, code is left to the coder.


No comments:

Post a Comment