-function g(int n){ 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:D
-function g(int n){ 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: In every case if a and b have different value always