First Equation of motion, How to implement using C language

The first equation of motion is used to calculate the final velocity of an object under constant acceleration.

Title image


Algorithm: 

Without wasting any of your precious time let's try to understand how the algorithm is implemented.
The first equation of motion is

want to check the implementation of Second equation of motionclick here.

v = u + a * t

u: initial velocity

t: time taken by the journey

a: constant acceleration

as you can see in our program we are considering u=0 if you want you can set initialVelocity variable value as per your choice or you can ask it from user too, accel=5 and timeOfJourney=7.

want to check the implementation of the Third equation of motion, click here.

In function, finalVelocityWithConstantAcceleration we have implemented the equation.

final_velocity = u * a * i

Code:

 
#include

// this is the implementation of 1st equations of motion.
void finalVelocityWithConstantAcceleration(int accel,float u,int xtime){
float final_velocity=0;
printf("Time\tVelocity\n");
for (int i=1;i<=xtime;i++){
final_velocity = u + (accel * i);
printf("%d s\t%f m/s\n",i,final_velocity);
}
}

int main() {
int accel=5;
int initialVelocity=0;
int timeOfJourney=7;
//printf("How much is the initial Velocity of element:");
//scanf("%f",&initialVelocity);
/* printf("Value of constant acceleration:");
scanf("%d",&accel);
printf("\n");
printf("Value of time:");
scanf("%d",&timeOfJourney);
printf("\n"); */
finalVelocityWithConstantAcceleration(accel,initialVelocity,timeOfJourney);
return 0;
}

The sample output of this code is.












Thanks for reading this, for any implementation please ask in the comment section.
want to check the implementation of Third equation of motion, click here.
want to check the implementation of Second equation of motionclick here.

Comments

Popular posts from this blog

C/C++ program to check the Palindrome string.

Second Equation of motion, How to implement using C language

Third Equation of motion, How to implement using C language