Functions that gets the largest of some values?

I'm writing two functions: One that gets the largest of two integers and one that gets the largest of three integers. The second function has to use first function without the if else statement.
1
2
3
4
5
6
7
int getLargOfTwo ( int a, int b )
{
if ( a > b )
return a;
else
return b;
}

1
2
3
4
5
6
7
8
int getLargOfThree ( int x, y, z )
{
int largest;
largest = getLargOfTwo( x ,y );
largest = getLargOfTwo( x ,z );
largest = getLargOfTwo( y ,z );
return largest;
}
After line 4 of getLargOfThree, largest has the value of whichever is larger, x or y. You want to call getLargOfTwo with largest and z as parameters. You only need to call that function twice.
Thanks!
Topic archived. No new replies allowed.