Algorithms | Recursion | Question 5

What does fun2() do in general?

filter_none

edit
close

play_arrow

link
brightness_4
code

int fun(int x, int y)
{
    if (y == 0)   return 0;
    return (x + fun(x, y-1));
}
  
int fun2(int a, int b)
{
    if (b == 0) return 1;
    return fun(a, fun2(a, b-1));
}

chevron_right


(A) x*y
(B) x+x*y
(C) xy
(D) yx


Answer: (C)

Explanation: The function multiplies x to itself y times which is xy.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.