GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2021 set2

GATE 2021 set2 · CS · NAT · 1 mark · Programming and Data Structures › Recursion

GATE 2021 set2 Computer Science and Information Technology question: Consider the following ANSI C function: code The value returned by SomeFunction(15, 255)…

Consider the following ANSI C function:

int SomeFunction(int x, int y)
{
    if ((x == 1) || (y == 1)) return 1;
    if (x == y) return x;
    if (x > y) return SomeFunction(x - y, y);
    if (y > x) return SomeFunction(x, y - x);
}

The value returned by SomeFunction(15, 255) is ______.

Show answer

Official answer: 15

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion