C Program To Find Distance And Velocity

C Program to find distance and velocity

The total distance travelled by vehicle in ‘t’ seconds is given by distance = ut+1/2at2 where ‘u’ and ‘a’ are the initial velocity (m/sec.) and acceleration (m/sec2).

/* Aim: Accept initial velocity(u),acceleration(a),and time(t).
Print the final velocity(v) and distance(s) traveled. */

#include<stdio.h>
void main()
{
 float u,a,t,v,s;
 
 printf("\n Enter initial velocity: ");
 scanf("%f",&u);

 printf("\n Enter acceleration: ");
 scanf("%f",&a);

 printf("\n Enter time required: "); 
 scanf("%f",&t); 

 v=u+a*t;
 s=u*t+(1/2)*a*t*t;

 printf("\n The final Velocity is : %f",v);
 printf("\n \n The distance traveled is : %f \n \n",s);

}

Output:

 Enter initial velocity: 12

 Enter acceleration: 12

 Enter time required: 12     

 The final Velocity is : 156.000000
 
 The distance traveled is : 1008.000000