/* find the larger and smaller of two numbers */ #include using namespace std; void find_max_min(int, int, int &, int &); //function prototype int main() { int a=1, b=2; int larger,smaller; find_max_min(a, b, larger, smaller); cout << "The larger is " << larger << " and the smaller is " << smaller << endl; find_max_min(5, a+b, larger, smaller); cout << "Now the larger is " << larger << " and the smaller is " << smaller << endl; // system("pause"); //un-comment when using DevC++ return 0; } /* Function find_max_min() * Input: * x - first integer * y - second integer * max - reference where to put larger value * min - reference where to put smaller value * Process: * The function stores the larger of x and y into max and * the smaller of x and y into min * Output: * max - the larger of the values * min - the smaller of the values */ void find_max_min(int x, int y, int &max, int &min) { if (x > y) { max = x; min = y; } else { max = y; min = x; } return; }