{if (n > 0) return 1;else return -1;} function f(int a, int b){if (a > b) return g(b-a);if (a < b) return g(-a+b); return 0; }If f(a,b) is called, what is returned?
A. Always +1
B. -1 if a > b, 1 if a < b, 0 otherwise
C. 1 if a > b, -1 if a < b, 0 otherwise
D. 0 if a equals b, -1 otherwise
Answer:B
{if (n > 0) return 1;else return -1;} function f(int a, int b){if (a > b) return g(b-a);if (a < b) return g(-a+b); return 0; }If f(a,b) is called, what is returned?
A. Always +1 B. -1 if a > b, 1 if a < b, 0 otherwise C. 1 if a > b, -1 if a < b, 0 otherwise D. 0 if a equals b, -1 otherwise
Explanation: if a>b then -1 otherwise a<b 1 rest 0