C++_Ball_programs

C++_Ball_programs - C+ programs called ball. #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
C++ programs called ball…………………. #include <iostream> using namespace std; int main() { double g=9.81;//acceleration due to gravity cout<<"Input the initial velocity (m/s):> "; double v0; cin>> v0 ; cout<< " Input the time (s):> "; double t; cin>> t; cout<< "==========================="// << endl; cout<< "The velocity at time " <<t<< " is " << v0 - g*t <<endl; cout<< "and the height is " << v0*t - (g*t*t)/2 << endl; return 0; } //================================================== //ball2.cpp //Code to compute the eventual overall height and velocity of a ball //launched with given iniyial velocity on Earth and Mars #include <iostream> using namespace std; int main() { double g=9.81;//acceleration due to gravity cout<<"Input the initial velocity (m/s):> "; double v0; cin>> v0 ; cout<< " Input the time (s):> "; double t;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C++ programs called ball…………………. cin>> t; //Results on Earth cout<< "==========================="// << endl; cout<< "Earth:"<<endl; cout<< "The velocity at time " <<t<< " is " << v0 - g*t <<endl; cout<< "and the height is " << v0*t - (g*t*t)/2 << endl; //Results on Mars g=3.63;//Acceleration due to gravity on Mars cout<< "==========================="// << endl; cout<< "Mars:"<<endl; cout<< "The velocity at time " <<t<< " is " << v0 - g*t <<endl; cout<< "and the height is " << v0*t - (g*t*t)/2 << endl;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

C++_Ball_programs - C+ programs called ball. #include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online