Skip to content
Related Articles

Related Articles

GATE | GATE CS 2021 | Set 2 | Question 59

Improve Article
Save Article
Like Article
  • Last Updated : 23 May, 2021

Consider the following ANSI C program

#include 
int foo(int x, int y, int q) 
    {
        if ((x<=0) && (y<=0))
        return q;
        if (x<=0)
        return foo(x, y-q, q);
        if (y<=0)
        return foo(x-q, y, q);
        return foo(x, y-q, q) + foo(x-q, y, q);
    }
int main( )
{
    int r = foo(15, 15, 10);
    printf(ā€œ%dā€, r);
    return 0;
} 

The output of the program upon execution is _________ .
(A) 60
(B) 10
(C) 15
(D) 50


Answer: (A)

Explanation:

Refer - https://ide.geeksforgeeks.org/AfA2f4YPoO

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!