250+ TOP MCQs on Multidimensional Arrays and Answers

C helps anyone preparing for Symantec and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Symantec interviews on C Programming language.

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

1. What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];)
a) func(a);
b) func(&a);
c) func(*a);
d) func(**a);
Answer: a
Clarification: None.

2. What are the applications of a multidimensional array?
a) Matrix-Multiplication
b) Minimum Spanning Tree
c) Finding connectivity between nodes
d) All of the mentioned
Answer: d
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3];
  5.         foo(ary);
  6.     }
  7.     void foo(int *ary[])
  8.     {
  9.         int i = 10, j = 2, k;
  10.         ary[0] = &i;
  11.         ary[1] = &j;
  12.         *ary[0] = 2;
  13.         for (k = 0;k < 2; k++)
  14.         printf("%dn", *ary[k]);
  15.     }

a) 2 2
b) Compile time error
c) Undefined behaviour
d) 10 2
Answer: a
Clarification: None.

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

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

a) Compile time error
b) 10 2
c) Undefined behaviour
d) segmentation fault/code crash
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         foo(ary);
  5.     }
  6.     void foo(int **ary)
  7.     {
  8.         int i = 10, k = 10, j = 2;
  9.         int *ary[2];
  10.         ary[0] = &i;
  11.         ary[1] = &j;
  12.         printf("%dn", ary[0][1]);
  13.     }

a) 10
b) 2
c) Compile time error
d) Undefined behaviour
Answer: d
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3][4], j = 20;
  5.         ary[0][0] = &j;
  6.         printf("%dn", *ary[0][0]);
  7.     }

a) Compile time error
b) 20
c) Address of j
d) Undefined behaviour
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[2][3];
  5.         ary[][] = {{1, 2, 3}, {4, 5, 6}};
  6.         printf("%dn", ary[1][0]);
  7.     }

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

Leave a Reply

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