{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# code 06 - cout<<"Please enter the height of the...

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

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 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 {

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

View Full Document
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

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

View Full Document

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

View Full Document
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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern