+ 1

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

2 Answers

+ 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;

0

Thanks !!