A good answer might be:Divide the sum by the number of elements. | |
Computing the AverageOf course, this is assuming that there are more than zero elements. Dividing by zero will always result in a run-time error. Here is the program with some additional statements for computing the average of the elements:
It might look a little strange to test if array contains any elements, since it is obvious that it does. However, in a more realistic program the array will come from some external source, and sometimes the array will have length zero. | |
QUESTION 15:Fill in the blanks. Click Here after you have answered the question |