GATE CS 2021 Set 2 | Question 20

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

  1. Question 20Programming & Data Structuresmcq1 mark
    Consider the following ANSI C program.
    #include <stdio.h>
    int main() {
        int arr[4][5];
        int i, j;
        for (i = 0; i < 4; i++)
            for (j = 0; j < 5; j++)
                arr[i][j] = 10 * i + j;
        printf("%d", *(arr[1] + 9));
        return 0;
    }
    The output of the program is ______.
    • A.
      14
    • B.
      20
    • C.
      24
      ✓
    • D.
      30

    Answer: C

    Solution

    arr[1] points to arr[1][0]. Adding 9 (row-major) reaches element at offset 9, i.e. arr[2][4] (row length 5: ). Its value is .

More GATE PYQ on Pointers

All GATE CS Programming & Data Structures PYQ →

Attempt GATE CS 2021 Set 2 in real GATE exam mode

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

Create free account →