// A simple program which uses a user defined function // Program reads three numbers from terminal out // outputs the max one. // uses the user defined function max to return the larger // of two numbers #include #include // function prototype -- "declares" user defined functions int max(int numb1, int numb2); main() { int i1, i2, i3, imax; cout << "Enter 3 integers: "; cin >> i1 >> i2 >> i3; imax = max(i1, i2); cout << "The maximum is: " << max(i3, imax) << endl; cout << "A quicker way to get max: " << max (i3, max(i1, i2)) << endl; return 0; } // definition of the user defined function // this function returns the larger of two integers int max(int numb1, int numb2) { if (numb1 > numb2) return(numb1); else return(numb2); }