250+ TOP MCQs on Multidimensional Arrays and Answers

C MCQs (multiple choice questions) on “Multidimensional Arrays”. One shall practice these MCQs to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our multiple choice questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C multiple choice questions on “Multidimensional Arrays” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int a[2][3] = {1, 2, 3, 4, 5};
  5.         int i = 0, j = 0;
  6.         for (i = 0; i < 2; i++)
  7.         for (j = 0; j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }

a) 1 2 3 4 5 0
b) 1 2 3 4 5 junk
c) 1 2 3 4 5 5
d) Run time error
Answer: a
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int a[2][3] = {1, 2, 3, , 4, 5};
  5.         int i = 0, j = 0;
  6.         for (i = 0; i < 2; i++)
  7.         for (j = 0; j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }

a) 1 2 3 junk 4 5
b) Compile time error
c) 1 2 3 0 4 5
d) 1 2 3 3 4 5
Answer: b
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     void f(int a[][3])
  3.     {
  4.         a[0][1] = 3;
  5.         int i = 0, j = 0;
  6.         for (i = 0; i < 2; i++)
  7.         for (j = 0; j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }
  10.     void main()
  11.     {
  12.         int a[2][3] = {0};
  13.         f(a);
  14.     }

a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
Answer: a
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     void f(int a[][])
  3.     {
  4.         a[0][1] = 3;
  5.         int i = 0, j = 0;
  6.         for (i = 0;i < 2; i++)
  7.         for (j = 0;j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }
  10.     void main()
  11.     {
  12.         int a[2][3] = {0};
  13.         f(a);
  14.     }

a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
Answer: c
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     void f(int a[2][])
  3.     {
  4.         a[0][1] = 3;
  5.         int i = 0, j = 0;
  6.         for (i = 0;i < 2; i++)
  7.         for (j = 0;j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }
  10.     void main()
  11.     {
  12.         int a[2][3] = {0};
  13.         f(a);
  14.     }

a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
Answer: c
Clarification: None.

6. Comment on the following C statement.

int (*a)[7];

a) An array “a” of pointers
b) A pointer “a” to an array
c) A ragged array
d) None of the mentioned
Answer: b
Clarification: None.

7. Comment on the following 2 arrays with respect to P and Q.

  1.    int *a1[8];
  2.    int *(a2[8]);
  3.    P. Array of pointers
  4.    Q. Pointer to an array

a) a1 is P, a2 is Q
b) a1 is P, a2 is P
c) a1 is Q, a2 is P
d) a1 is Q, a2 is Q
Answer: b
Clarification: None.

8. Which of the following is not possible statically in C?
a) Jagged Array
b) Rectangular Array
c) Cuboidal Array
d) Multidimensional Array
Answer: a
Clarification: None.

Leave a Reply

Your email address will not be published. Required fields are marked *