C++ Function Definition Finds minimum and maximum values
#include <iostream> using namespace std; int maximum(int num1, int num2); int minimum(int num1, int num2); int main()// ww w . j ava 2s .co 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); }