Consider the C program shown below. #include <stdio.h> #define print(x)…

GATE · 2003 · CS

Consider the C program shown below.

#include <stdio.h>
#define print(x) printf("%d ", x)
int x;
void Q(int z)
{
    z += x;
    print(z);
}
void P(int *y)
{
    int x = *y + 2;
    Q(x);
    *y = x - 1;
    print(x);
}
main(void)
{
    x = 5;
    P(&x);
    print(x);
}

The output of this program is

  1. A.

    12 7 6

  2. B.

    22 12 11

  3. C.

    14 6 6

  4. D.

    7 6 6

Attempted by 209 students.

Show answer

Correct answer: A

The worked solution is available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…