GATE CS 2022 (Forenoon) — Question 43

Programming in CPointers, Multi-Dimensional Arrays, StructuresMCQ2 marks · −2/3 if wrongMedium

What is printed by the following ANSI C program?
c
1#include<stdio.h>
2int main(int argc, char *argv[ ])
3{
4    int a[3][3][3] = {{1, 2, 3, 4, 5, 6, 7, 8, 9},
5                      {10, 11, 12, 13, 14, 15, 16, 17, 18},
6                      {19, 20, 21, 22, 23, 24, 25, 26, 27}};
7    int i = 0, j = 0, k = 0;
8    for(i = 0; i < 3; i++) {
9        for(k = 0; k < 3; k++)
10            printf("%d ", a[i][j][k]);
11        printf("\n");
12    }
13    return 0;
14}
15
  1. A
    1 2 3 10 11 12 19 20 21
  2. B
    1 4 7 10 13 16 19 22 25
  3. C
    1 2 3 4 5 6 7 8 9
  4. D
    1 2 3 13 14 15 25 26 27
Practise the full 2022-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAPractise this subject in the exam simulatorTimed, GATE-style tests with analytics that find your weak topics.
Practise more on Pointers, Multi-Dimensional Arrays, StructuresTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group