Skip to content
Related Articles
Open in App
Not now

Related Articles

Algorithms | Recursion | Question 4

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

What does the following function do?




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


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


Answer: (C)

Explanation: The function adds x to itself y times which is x*y.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!