ISRO | ISRO CS 2017 | Question 73

Consider the function

int fun(x: integer)
{
If x > 100 then fun = x – 10;
else
fun = fun(fun(x + 11));
}

For the input x = 95, the function will return
(A) 89
(B) 90
(C) 91
(D) 92


Answer: (C)

Explanation: f(95)–>f(f(106)) = f(96)–>f(f(107)) = f(97)–>f(f(108)) = f(98)–>f(f(109)) = f(99)–>f(f(110)) = f(100)–>f(f(111)) = f(101) = 91
So the correct option is (C)

Quiz of this Question



My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.