C Program - Accept initial Velocity (u), acceleration (a) and time (t). print the final velocity (v) and the distance (s) travelled .


Program

#include<stdio.h>
void main()                    
{
   int sec;
   float distance , initial_velocity,velocity, acceleration;
      printf("Enter the time in seconds \n");
      scanf("%d",&sec);
      printf("Enter the initial velocity \n");
      scanf("%f", &initial_velocity);
      printf("Enter the acceleration \n");
      scanf("%f", &acceleration);
      velocity = (initial_velocity + (acceleration * sec));
      distance = (initial_velocity + (acceleration * (sec*sec)));\
   printf("Total velocity is %f",velocity);
   printf("Total distance travelled is  %f", distance);

}

Output:

Enter the time in seconds
60
Enter the initial velocity
5
Enter the acceleration
7
Total velocity is 425.000000Total distance travelled is  25205.000000

--------------------------------

Post a Comment

2 Comments