Given the following code. Show the dry run/ working .
int fun(int a, int b)
{
if(b == 0)
return 0;
if(b % 2 == 0)
return fun(a + a, b/2);
return fun(a + a, b/2) + a;
}
(i) What will be output for the call fun(3, 2)? [2]
(ii) What will be output for the call fun(4, 3)? [2]
(iii) What is the function fun() doing?
Answers
Answered by
0
Answer:
6
12
Fun() is a recursive function calling itself
Similar questions