Computer Science, asked by saismitadas999, 6 months ago

can anyone fix this code?


double distance1(double u, double a, double v)
{ return (v*v - u*u)/2*a;
}
// This function is SUPPOSED to calculcate the
// distance (in metres) traveled by an object
// moving at initial velocity u (in metres per
// second) with uniform acceleration a (in
// metres per second square) for time t (in // seconds).
// Fix the code. Recall: s = u*t + (1/2)*a*t*t
double distance2(double u, double a, double t)
{ return u*t + (1/2)*a*t*t;
}
#include
int main(void)
{
double u, a, t, v;
while (1)
{
printf("Initial velocity u: ");
scanf("%lf", &u);
do {
printf("Non-zero acceleration a: ");
scanf("%lf", &a);
}
while (a == 0.0);
printf("Time t: ");
scanf("%lf", &t);
v = u + a*t;
printf("Distance s: %lf\n", distance1(u, a, v));
printf("Distance s: %lf\n", distance2(u, a, t));
}
return 0;

}

Answers

Answered by rishushukla740
1

Explanation:

);

printf("Time t: ");

scanf("%lf", &t);

v = u + a*t;

printf("Distance s: %lf\n", distance1(u, a, v));

printf("Distance s: %lf\n", distance2(u, a, t));

}

return 0;

Answered by priteshsaluja621
1

Answer:

no bro but yes bro .... ..

Similar questions