What does the following program print? #include <stdio.h> void f(int *p, int…

GATE · 2010 · CS · Computer Science & IT

What does the following program print?

#include <stdio.h>
void f(int *p, int *q) {
    p = q;
    *p = 2;
}
int i = 0, j = 1;
int main() {
    f(&i, &j);
    printf("%d %d\n", i, j);
    return 0;
}
  1. A.

    2 2

  2. B.

    2 1

  3. C.

    0 1

  4. D.

    0 2

Attempted by 390 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…