I'm trying to calculate the average of specific lines in an array. For example the format of the array looks like this:
float Array[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,...20}
I want to calculate the average of the first 5 numbers in the array, then the average of the next 5 numbers and so on... storing them into another array with only the averages of those numbers.
Here's my code so far
float average_values[4];
for (int a = 0; a < 4; a++){ //20 elements in array divided by 5 = 4
float sum = 0;
for (int b = 0; b < (20 / 4); b++){
sum = sum + scores[b];
}
average_values[i] = sum / (20 / 4);
}