GATE CS 2022 | Question 21

Programming & Data Structures › Pointers · MCQ · 1 mark · Answer: D

  1. Question 21Programming & Data Structuresmcq1 mark
    What is printed?
    int x = 1, z[2] = {10, 11};
    int *p = NULL;
    p = &x;  *p = 10;
    p = &z[1];
    *(&z[0] + 1) += 3;
    printf("%d, %d, %d\n", x, z[0], z[1]);
    • A.
      1, 10, 11
    • B.
      1, 10, 14
    • C.
      10, 14, 11
    • D.
      10, 10, 14
      ✓

    Answer: D

    Solution

    Answer: (D) 10, 10, 14 *p=10 with p=&x sets . &z[0]+1 is &z[1], so *(&z[0]+1) += 3 makes . is unchanged (10). Output: "10, 10, 14".

More GATE PYQ on Pointers

All GATE CS Programming & Data Structures PYQ →

Attempt GATE CS 2022 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →