Quick Quiz on Recursion with Numbers!

Quiz on recursion with numbers.

1

What is the output of the following code?

int foo(int n)
{
    if (n == 12)
    {
     return n;
    }
    else 
    {
      return foo(n+1);
    }
}
 
int main()
{
   cout<<foo(3);
   return 0;
}
A)

75

B)

12

C)

3

Question 1 of 20 attempted

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.