Consider the following C program main() { int x, y, m, n; scanf("%d %d", &x,…

GATE · 2004 · CS

Consider the following C program

main()
{
    int x, y, m, n;
    scanf("%d %d", &x, &y);
    /* Assume x > 0 and y > 0 */
    m = x;
    n = y;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    printf("%d", n);
}

The program computes

  1. A.

    x ÷ y using repeated subtraction

  2. B.

    x mod y using repeated subtraction

  3. C.

    the greatest common divisor of x and y

  4. D.

    the least common multiple of x and y

Attempted by 452 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…