+ 1

How to calculate the average of a set of numbers in an array with a for loop?

5th Apr 2017, 6:01 PM
Luis Armando Colón
2 odpowiedzi
+ 5
average is the sum / number of elements. So: int sum = 0; for( int i = 0; i < array.length; i++) sum += array[i]; int average = sum / array.length;
5th Apr 2017, 6:03 PM
Rrestoring faith
Rrestoring faith - avatar
0
Thanks !!
5th Apr 2017, 6:05 PM
Luis Armando Colón