GATE CS 2022 | Question 43

Programming & Data Structures › Arrays & Strings · MCQ · 2 marks · Answer: A

  1. Question 43Programming & Data Structuresmcq2 marks
    What is printed? (a[3][3][3] initialized row-wise with 1..27; loops over i and k with j=0, printing a[i][j][k].)
    • A.
      1 2 3 / 10 11 12 / 19 20 21
      ✓
    • B.
      1 4 7 / 10 13 16 / 19 22 25
    • C.
      1 2 3 / 4 5 6 / 7 8 9
    • D.
      1 2 3 / 13 14 15 / 25 26 27

    Answer: A

    Solution

    Answer: (A) 1 2 3 / 10 11 12 / 19 20 21 The array stores values in row-major order, so is element at offset . For : ; : ; : . With fixed at 0 the output is those three rows.

More GATE PYQ on Arrays & Strings

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 →