The average of the first data set should be: (80+70+65+89+90)/5 and the second set (85+80+80+82+87)/5, but for some reason my code is not working.
When I run the code I get 17.0 and 219886384 instead of 78.8 and 82.8.
int main(void)
{
int grades[2][5] = {{80, 70, 65, 89, 90}, {85, 80, 80, 82, 87}};
float average;
int sum;
int i;
int j;
for(i = 0; i < 2; i++)
{
sum = 0;
for(j = 0; j < 5; j++);
{
sum += grades[i][j];
}
average = sum / 5;
printf("The average grade for %d is: %f\n", i, average);
}
return 0;
}