Home C Language Basic C Programs Calculate distance traveled

Calculate distance traveled

Write C program to find the distance traveled at regular intervals of time given the values of ‘u’ and ‘a’.


int main()


int t; //’t’ for time

float a,u,d; //’a’ for Acceleration, ‘u’ for initial velocity, ‘d’ for distance.

printf(“Enter time in seconds : “);


printf(“Enter initial velocity : “);


printf(“Enter Acceleration : “);


d=(u*t)+(a*t*t)/2; //Calculate Distance by predefined formula.

printf(“Traveled distance is : %.2f”,d);

return 0;


Output :

Enter time in seconds: 13

Enter initial velocity : 4

Enter Acceleration : 4.8

Traveled distance is : 457.60