I have a program I have to write that reads a data file. The data file has four columns(time, altitude, velocity, acceleration). I am supposed to read this data file and find out when the rocket is falling back to Earth. I would do this by finding when the altitude starts to drop off. When the altitude drops off I am supposed to print the time that it starts to drop off to the screen.
I got a program together but it is not printing off the time that is corresponding to the time the altitude starts to drop off.
Here is the program:
#define FILENAME "rocket11.txt"
int max_found=0, k, lines;
double time1, time2, time3, alt1, alt2, alt3, vel, acc;
FILE * data;
/* Open file and read the number of data points. */
data = fopen(FILENAME,"r");
if (data == NULL)
printf("Error opening input file. \n");
fscanf(data, "%d", &lines);
/* Read data and compute summary information. */
for (k=1; k<=lines; k++);
fscanf(data, "%lf %lf %lf %lf",&time1, &alt1, &vel, &acc);
fscanf(data, "%lf %lf %lf %lf",&time2, &alt2, &vel, &acc);
fscanf(data, "%lf %lf %lf %lf",&time3, &alt3, &vel, &acc);
printf("Rocket is returning to Earth at %lf (s)",time2);