Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //To determine the velocity and distance travel of a car
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main ()
- {
- double ivelocity; //initial velocity
- double time; //time
- double acceleration; //acceleration
- double fvelocity; //final velocity
- double distance; //distance,(m)
- cout<<"Initial velocity"<<endl<<"=>";
- cin>>ivelocity;
- cout<<"Time taken (in seconds)"<<endl<<"=>";
- cin>>time;
- cout<<"Acceleration"<<endl<<"=>";
- cin>>acceleration;
- fvelocity=ivelocity+acceleration*time;
- distance=ivelocity*time+(acceleration*pow(time,2)/2);
- cout<<"The car travel up to "<<distance<<"m, with velocity "<<fvelocity<<"m/s after "<<time<<"s"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement