0

Hi guys,

so im required to write a programme that will make a table, along with the values and all and im also required to mark "X" at the minimum value of total time A+B (exactly beside the minimum value in the table).

I tried using if statement but it doesnt work at all. Im quite new in programming so please help me :(

```
#include <stdio.h>
#include <math.h>
#define v1 3 //Velocity at Beach
#define v2 1.5 //Velocity in Water
int main()
{
float Xo=0, a=0, b=0;
float c=0, distanceA=0, distanceB=0, timeA=0, timeB=0, totaldistance=0, totaltime=0, totaltimeold=0, totaltimenew=0;
printf("Give the value of Xo min: ");
scanf("%f", &a);
printf("Give the value of Xo max: ");
scanf("%f", &b);
printf("Give the range between the values: ");
scanf("%f", &c);
printf("Xo\tDistance A\tDistance B\tTime A\tTime B\t Total distance A+B\t Total time A+B\n");
printf("________________________________________________________________________________\n\n");
for(Xo=a; Xo<=b; Xo=Xo+c)
{
distanceA = sqrt((20*20) + (Xo*Xo));
timeA = distanceA/v1;
distanceB = sqrt(30*30 + (50-Xo)*(50-Xo));
timeB = distanceB/v2;
totaldistance = distanceA + distanceB;
totaltime = totaltimeold;
totaltimeold = totaltimenew;
totaltimenew = timeA + timeB;
if((totaltime==0 && totaltimeold!=0 && totaltimenew>totaltimeold) || (totaltimeold<totaltimenew && totaltimeold<totaltime )) printf("x"), Xo=Xo+c;
printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t\t%.2f\t\t%.2f\n", Xo, distanceA, distanceB, timeA, timeB, totaldistance, totaltimenew);
}
getchar();
getchar();
return 0;
}
```