Write program to calculate the distance from second equation of linearly accelerated motion. The formula for the calculation is
S=u*t+(/2*a*t*t
#include <iostream>
using namespace std;
int main()
{
cout << "Please enter u,t,a:\n";
cout << "u=";
double v, t, a;
cin >> v;
cout << "t=";
cin >> t;
cout << "a=";
cin >> a;
double S = v * t + (a * t * t)/2.0;
cout << "S=" << S << endl;
return 0;
}
/*
for example
u=5 (speed)
t=2 (time)
a=1 (acceler)
S=5*2+1/2*1*2*2
=10+0.5*4
=12
*/
Comments
Leave a comment