Write a C++ program that calculates the final velocity of an object by taking following inputs from the user: vi = Initial velocity, a = acceleration, t = time span. Formula vf = vi + at.

 #include<iostream>

using namespace std;

int main()

{

int vi, vf, a, t;

cout<<"Enter the initial velocity: ";

cin>>vi;

cout<<"Enter the accleration: ";

cin>>a;

cout<<"Enter the time: ";

cin>>t;

vf = vi + a*t;

cout<<"The final veloity is "<<vf<<endl;

}

OUTPUT

Enter the initial velocity: 20

Enter the accleration: 10

Enter the time: 5

The final veloity is 70

1 comment: