//ic210 sec4002 //different ways of dealing with //function input and output #include #include using namespace std; // Write prototypes for THREE functions here int getMax1(int, int); void getMax2(int, int, int&); int getMinAndMax(int, int, int&); // This program demonstrates different ways to use functions int main() { int x = 5, y = 7, min, max; // One way to the max max = getMax1(x, y); cout << "Try 1: max is: " << max << endl; // Another way to get the max getMax2(x, y, max); cout << "Try 2: max is: " << max << endl; // Yet another way -- this one finds the minimum too max = getMinAndMax(y, x, min); cout << "Try 3: max is: " << max << ", min is " << min << endl; return 0; } int getMax1(int x, int y) { if(x>=y) return x; else return y; } void getMax2(int x, int y, int& max) { if(x>=y) max= x; else max= y; } int getMinAndMax(int x, int y, int& min) { if(x>=y) { min = y; return x; } else { min = x; return y; } }