Answer to Question #284844 in C++ for Tatheer

Question #284844

Dry run the following code and draw the tree to show how recursion is solved. On writing only


output you will get zero number.


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;


}


int main()


{


cout << fun(4, 3) ;


return 0;


}

1
Expert's answer
2022-01-05T16:26:03-0500

The answer to your question is provided in the image:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog