Computer Science, asked by shreysthb, 7 months ago

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 drishtisingh156
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 vaibhavshinde145
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