Home Uncategorized Write C program to find the distance traveled at regular intervals of...

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

SHARE

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

#include<stdio.h>
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 : “);
   scanf(“%d”,&t);
   printf(“Enter initial velocity : “);
   scanf(“%f”,&u);
   printf(“Enter Acceleration : “);
   scanf(“%f”,&a);
   d=(u*t)+(a*t*t)/2; //Calculate Distance by predefined formula.

   printf(“Travelled distance is : %2f”,d);
   return 0;
}

Output :
Enter time in seconds: 13
Enter initial velocity : 4
Enter Acceleration : 4.8
Travelled distance is : 457.60

Back to the programs list.