function g(int n)
{
if (n > 0) return 1;
else return -1;
}
function f(int a, int b)
{
if (a > b) return g(a-b);
if (a < b) return g(-b+a);
return 0;
}
If f(a,b) is called, what is returned?
Option 1 : Always +1
Option 2 : 1 if a > b, -1 if a < b, 0 otherwise
Option 3 : -1 if a > b, 1 if a < b, 0 otherwise
Option 4 : 0 if a equals b, -1 otherwise
Answer: Option 2