How I can do this? I mean which offline ide you are using and how to check the call stack after execution?

Dark Mode

39 votes

Best answer

Value returned by $\text{fun}(95) = \text{fun}(\text{fun}(106))$

$\qquad\qquad= \text{fun}(96)$

$\qquad\qquad= \text{fun}(\text{fun}(107))$

$\qquad\qquad= \text{fun}(97)$

$\qquad\qquad= \text{fun}(\text{fun}(108))$

$\qquad\qquad= \text{fun}(98)$

$\qquad\qquad = \text{fun}(\text{fun}(109))$

$\qquad\qquad= \text{fun}(99)$

$\qquad\qquad= \text{fun}(\text{fun}(110))$

$\qquad\qquad= \text{fun}(100) $

$\qquad\qquad= \text{fun}(\text{fun}(111)) $

$\qquad\qquad= \text{fun}(101) = 91.$

Correct Answer: $C$

$\qquad\qquad= \text{fun}(96)$

$\qquad\qquad= \text{fun}(\text{fun}(107))$

$\qquad\qquad= \text{fun}(97)$

$\qquad\qquad= \text{fun}(\text{fun}(108))$

$\qquad\qquad= \text{fun}(98)$

$\qquad\qquad = \text{fun}(\text{fun}(109))$

$\qquad\qquad= \text{fun}(99)$

$\qquad\qquad= \text{fun}(\text{fun}(110))$

$\qquad\qquad= \text{fun}(100) $

$\qquad\qquad= \text{fun}(\text{fun}(111)) $

$\qquad\qquad= \text{fun}(101) = 91.$

Correct Answer: $C$

0

If you see the 3^{rd} last step, we have fun(100). The code says :-

If x > 100 then fun = x – 10 Else fun = fun(fun (x+11))

Now fun(100) = fun(fun(111)) // Since 100 is not > 100.

= fun(101) // since 111 > 100

now this is unlike the other terms which were < 100, so we need to add 11.

Here 101 > 100, thus we again subtract 10 from 101

→ fun = 101-10 = $91$

0