First, indentation!
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
int k;
double time, height, time1, height1, time2, height2;
FILE *mydata;
mydata = fopen("F:\\Flight.txt", "r");
{
k = fscanf(mydata, "%lf %lf", &time1, &height2);
}
{
printf("Enter a time\n");
scanf("%lf", &time);
while (k == 2) {
fscanf(mydata, "%lf %lf", &time2, &height2);
if (time1 =< time =< time2) {
height = height1 + ((time - time1) / (time2 - time1)) - (height2 - height1);
return height;
printf("The height is %lf\n", &height);
break;
} else {
time1 = time2;
height1 = height2;
}
}
fclose(mydata);
system("PAUSE");
return (0);
}
}
line 19 - when do you assign k for this comparison to pass/fail at some point.
line 21 - you need to express it as a <= b && b <= c
line 23 - stops lines 24 and 25 from ever happening
line 24 - read up on printf - you don't need & when printing values.