diff options
Diffstat (limited to 'C++/FindLargestNumber/FindLargestNumber.cpp')
-rw-r--r-- | C++/FindLargestNumber/FindLargestNumber.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/C++/FindLargestNumber/FindLargestNumber.cpp b/C++/FindLargestNumber/FindLargestNumber.cpp new file mode 100644 index 0000000..e03f5ac --- /dev/null +++ b/C++/FindLargestNumber/FindLargestNumber.cpp @@ -0,0 +1,39 @@ +#include <iostream> +using namespace std; + +//Function decleration/prototype +//Functions are created in order from top to bottom +double larger(double x, double y); +double threelarger(double x, double y, double z); + +int main() { + double num1, num2, num3; + cout << "find the largest of two numbers \n\n"; + cout << "enter number 1: "; + cin >> num1; + cout << "enter number 2: "; + cin >> num2; + cout << "enter number 2: "; + cin >> num3; + + answer = threelarger(num1, num2, num3); + + cout << "the largest of the three numbers you entered is: " << larger(num1,num2) << endl; + +} + +double threelarger (double x, double y) { + double max; + + if (x > y) { + max = x; + } else { + max = y; + } + + return max; +} + +double larger (double x, double y) { + return larger(x, larger(y,z)); +} |