-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?
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
-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?
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 both same answer is 0 then a>b then 1 otherwise -1