C++_Ball_programs

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

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

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;

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

View Full Document
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;
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/06/2011 for the course HANDOUT 502 at USC.

### 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
Ask a homework question - tutors are online