I'm trying to make a program that asks how many days have you practiced, and then for each day ask how many flights you made and then determine the average of those flights for each day, this is my code right now:
#include <stdio.h>
int main() {
int days, flights, i;
double length, total, average;
printf("How many days have you been practicing?\n");
scanf("%d", &days);
for(i=1; i<=days; i++) {
printf("How many flights were completed in day #%d?\n", i);
scanf("%d", &flights);
for(i=1; i<=flights; i++){
printf("How long was flight #%d?\n", i++);
scanf("%lf", &length);
length += total;
average = total / flights;
printf("Day #%d: The average distance is %.3lf\n", i, average);
}
}
return 0;
}
Right now I get to the part where I enter how long flight #1 was, but when I input a value the program stops working and I can't continue so I'm not sure if I have any other problems after that. Any help would be greatly appreciated as I am new to this! As an example the final output should look something like this:
How many days have you been practicing?
2
How many flights were completed in day #1?
2
How long was flight #1?
5.00
How long was flight #2?
10.00
Day #1: The average distance is 7.500.
How many flights were completed in day #2?
3
How long was flight #1?
7.50
How long was flight #2?
13.00
How long was flight #3?
15.75
Day #2: The average distance is 12.083.