Ok, so what I need to do is calculate the average distance of flights per day, as inputed by the user. My problem is that I have built the program, and instead of averaging each day individually, the program is averaging all of the flight data. Any help would be very appreciated. Here is the code below.
//Libraries
#include <stdio.h>
int main(){
//variables
int days, flights, i=1, j=1;
float distance=0,sum_total, avg;
//ask user input
printf("How many days has your dragon been practicing?\n");
scanf("%d", &days);
//while loops
while (i<=days){
printf("How many flights were completed in day %d\n", i);
scanf("%d", &flights);
for (j=1; j<=flights; j++){
printf("How far was flight %d\n", j);
scanf("%f", &distance);
sum_total+=distance;
avg=sum_total/flights;
}
printf("Day %d: The average flight distance was %f\n\n", i, avg);