lots_of_easy_functions

# lots_of_easy_functions - temp = len wid return temp double...

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

Sheet1 Page 1 #include <iostream> using namespace std int round(double rNum) double areaRect(double len, double wid) double areaRect2(double len, double wid) double areaTriangle(double base, double height) double computeAve(int num1, int num2, int num3) double findMedian(int num1, int num2, int num3) int main() { cout << round(13.5) << endl cout << areaRect(10, 5) << endl cout << areaRect2(10, 5) << endl cout << areaTriangle(10, 5) << endl cout << computeAve(3, 4, 5) << endl cout << findMedian(2, 1, 6) << endl return 0 }// end of main int round(double rNum) { rNum = int (rNum + 0.5) return rNum } double areaRect(double len, double wid) { return len * wid } double areaRect2(double len, double wid) { double temp = 0.0

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: temp = len * wid return temp } double areaTriangle(double base, double height) { // pick any return statement //return 1. / 2 * base * height //return .5 * base * height return base * height / 2 } double computeAve(int num1, int num2, int num3) { int sum = 0 Sheet1 Page 2 double answer = 0.0 sum = num1 + num2 + num3 answer = sum / 3.0 return answer } double findMedian(int num1, int num2, int num3) { if (num1 > num2 && num1 < num3) { return num1 } else if (num1 < num2 && num1 > num3) { return num1 } else if (num2 > num1 && num2 < num3) { return num2 } else if (num2 < num1 && num2 > num3) { return num2 } else { return num3 } }...
View Full Document

## This note was uploaded on 04/01/2008 for the course CMPSC 101 taught by Professor Drobish,renee during the Spring '07 term at Penn State.

### Page1 / 2

lots_of_easy_functions - temp = len wid return temp double...

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

View Full Document
Ask a homework question - tutors are online