C program Accept initial velocity, acceleration and time Print the final velocity and the distance travelled - IprogramX

Q. Accept initial velocity (u), acceleration (a) and time (t). Print the final velocity (v) and the distance (s) travalled . (Hint: v = u + at, s = u + at2)
Q. find distance with velocity and time and acceleration.


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("\n 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.000000
Total distance travelled is  25205.000000

Post a Comment

0 Comments