What will be returned if f(a,b) is called in the following functions?
function g(int n)
{
if (n>0) return 1;
else return -1;
function f(int a, int b)
if (a>b) return gla-b);
if (a<b) retum g(b-a);
return 0;
Answers
Answered by
120
function operation (int a, int b){if (a > b){ return operation(b, a) }else{ return a; }}Op 1: Always returns the first parameterOp 2: Returns the min of (a,b)Op 3: Returns the max of (a,b)Op 4: Loops foreverOp 5:Correct Op : 2Ques. 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?Op 1: Always -1Op 2: 1 if a > b, -1 if a < b, 0 otherwiseOp 3: -1 if a > b, 1 if a < b, 0 otherwiseOp 4: 0 if a equals b, -1 otherwise
Answered by
32
Answer:
0 if a equals b,1 if a>b ,-1 if a<b
Explanation:
Similar questions