Consider the following ANSI C program:
The output of the program upon execution is _________.
c
Programming in CFunctions, Parameter Passing, Scope Rules, RecursionNAT2 marksHard
1#include <stdio.h>
2int foo(int x, int y, int q)
3{
4 if ((x <= 0) || (y <= 0))
5 return q;
6 if (x <= 0)
7 return foo(x, y - q, q)
8 if (y <= 0)
9 return foo(x - q, y, q);
10 return foo(x, y - q, q) + foo(x - q, y, q);
11}
12int main( )
13{
14 int r = foo(15, 15, 10);
15 printf("%d", r);
16 return 0;
17}
18A GATE question every morning
One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.