Hi guys I'm struggling to find my footing with this homework problem.
The task is:
Write a question that has two input parameters, x and y, and two output parameters, small and big. The function should return the smaller of the inputs through small and the larger through big.
If anyone could assist that would be great! Thanks!
So a function call can't return 2 things. It can return only 1 thing.
So you can create 2 functions or 1 function with an option (smallest or biggest).
Function with the option:
1 2 3 4 5 6 7 8 9
int smallBig(char option, int x, int y, int small = 0, int big = 0)
{
if (x == y) { return x + y; } // error if they are equal
small = (x < y) ? x : y;
big = (x > y) ? x : y;
return (option == 's') ? small : big; // 's' means "smallest"
}