GATE CS 2021, set 2 · Question 59 · Programming and Data Structures · Numerical answer (NAT) · 2 marks · no negative marks
Consider the following ANSI C program.
#include <stdio.h> 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 ______.
Answer
Answer 60
Answer from the official GATE CS 2021 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes