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
4
if(b == 0)
return 0;
if(b % 2 == 0)
return fun(a + a, b/2);
return fun(a + a, b/2) + a;
follow me
Answered by
2
if(b == 0)
return 0;
if(b % 2 == 0)
return fun(a + a, b/2);
return fun(a + a, b/2) + a;
♥️♥️………follow me.......♥️♥️
Similar questions