C Program to Calculate Final Velocity

Here's the complete program to calculate final velocity in C language.

How to calculate final velocity in C language
How this Program Works?

First, we'll take the value of initial velocity, time and acceleration from the user as input.

Then, we'll apply condition if time is positive then put the values of acceleration, time and initial velocity in the formula to calculate the value of final velocity.

If the condition is false means time is negative then the program will end, because time can't be negative.

C Program To Calculate Final Velocity

#include<stdio.h>

void main(){

//declaration of variable
float v,t, acc, fv;

//getting the value of initial velocity from user
printf("Enter the Value Of Initial Velocity 'V' ");
scanf("%f",&v);

//getting the value of time from user
printf("Enter the Value Of Time 'T' ");
scanf("%f",&t);

//getting the value of acceleration from user
printf("Enter the Value Of acceleration 'A' ");
scanf("%f",&acc);

if( t > 0 ) //applying condition since time can't be negative
{
// formula to calculate final velocity
fv = ( v + ( acc * t ) );
printf("With the inital velocity %f, time %f and acceleration %f, the value of final velocity is %f m/s", v, t, acc, fv);
}
else
{
printf("Time can't be negative");
}
}

Related:



Comments

Popular posts from this blog

Pseudocode to Check, Number is Odd or Even

How to Create Marksheet in C