Code 06 - cout<<"Please enter the height of the bounce"<<endl cin>> z cout<<"The ball will bounce"<<

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

View Full Document Right Arrow Icon
Sheet1 Page 1 b. You can either put it at the top, or at the bottom, but only if you declare it first at the top. c. No, only function declarations. #include <iostream> // The integer value "z = 5" is only defined in the main function and its scope only pertains to the main fun c using namespace std int F(int z) { int x = 2 return z +=x } int main() { int z = 5 F(z) cout << "z = " << F(z) << endl return 0 } #include <iostream> #include <cmath> using namespace std float rise(float x) { float hAns = 0 hAns = 200/pow(2, x) return hAns } float xheight(float z) { return z/2 } int main(void) { int iCount = 0, iMax = 0 float iAns = 0.0 for( iCount=1 {
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 iAns = iAns + (200/pow(2.0,iCount)) } float z = 0 cout<<"The ball has travelled "<< iAns + 100 <<" feet after ten bounces."<<endl cout<<"The ball will rise " << rise(10) <<" feet after the tenth bounce."<<endl
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout <<"Please enter the height of the bounce."<<endl cin >> z cout <<"The ball will bounce " << xheight(z) <<" feet on the next bounce."<<endl return 0 } #include <iostream> using namespace std int mult(int x, int y, int z) { return x*y*z } float mult(float x, float y, float z) { return x*y*z } double mult(double x, double y, double z) { return x*y*z } int main(void) { int ix = 2, iy = 3, iz = 4 float fx = 3, fy= 4, fz = 5 double dx = 4, dy = 5, dz = 6 d cout <<"The answer is " << mult(ix, iy, iz) <<endl Sheet1 Page 3 cout <<"The answer is " << mult(fx, fy, fz) <<endl cout <<"The answer is " << mult(dx, dy, dz) <<endl return 0 } Sheet1 Page 4 iCount <= 10 iCount++ ) Sheet1 Page 5 //The extra 100 is for the intial drop of the ball Sheet1 Page 6...
View Full Document

This note was uploaded on 04/13/2010 for the course ME me205 taught by Professor Pryor during the Spring '09 term at University of Texas-Tyler.

Page1 / 6

Code 06 - cout<<"Please enter the height of the bounce"<<endl cin>> z cout<<"The ball will bounce"<<

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

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