lots_of_easy_functions

lots_of_easy_functions - temp = len * wid return temp }...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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 &gt; num2 &amp;&amp; num1 &lt; num3) { return num1 } else if (num1 &lt; num2 &amp;&amp; num1 &gt; num3) { return num1 } else if (num2 &gt; num1 &amp;&amp; num2 &lt; num3) { return num2 } else if (num2 &lt; num1 &amp;&amp; num2 &gt; num3) { return num2 } else { return num3 } }...
View Full Document

Page1 / 2

lots_of_easy_functions - temp = len * wid return temp }...

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

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