C++ examples for Function:Function Return
Finds minimum and maximum values in functions.
#include <iostream> using namespace std; int maximum(int num1, int num2); int minimum(int num1, int num2); int main()//from w w w .jav a2 s . c o m { int num1, num2; int min, max; cout << "Please type two numbers (such as 46 75) "; cin >> num1 >> num2; max = maximum(num1, num2); min = minimum(num1, num2); cout << "The minimum number is " << min << "\n"; cout << "The maximum number is " << max << "\n"; return 0; } int maximum(int num1, int num2) { int max; max = (num1 > num2) ? (num1) : (num2); return (max); } int minimum(int num1, int num2) { int min; min = (num1 < num2) ? (num1) : (num2); return (min); }