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);
View Answer
Explanation: None.
2. Applications of multidimensional array are?
a) Matrix-Multiplication
b) Minimum Spanning Tree
c) Finding connectivity between nodes
d) All of the mentioned
View Answer
Explanation: None.
3. What is the output of this C code?
#include <stdio.h>
int main()
{
int ary[2][3];
foo(ary);
}
void foo(int *ary[])
{
int i = 10, j = 2, k;
ary[0] = &i;
ary[1] = &j;
*ary[0] = 2;
for (k = 0;k < 2; k++)
printf("%d\n", *ary[k]);
}
a) 2 2
b) Compile time error
c) Undefined behaviour
d) 10 2
View Answer
Explanation: None.
4. What is the output of this C code?
#include <stdio.h>
int main()
{
int ary[2][3];
foo(ary);
}
void foo(int (*ary)[3])
{
int i = 10, j = 2, k;
ary[0] = &i;
ary[1] = &j;
for (k = 0;k < 2; k++)
printf("%d\n", *ary[k]);
}
a) Compile time error
b) 10 2
c) Undefined behaviour
d) segmentation fault/code crash
View Answer
Explanation: None.
5. What is the output of this C code?
#include <stdio.h>
int main()
{
foo(ary);
}
void foo(int **ary)
{
int i = 10, k = 10, j = 2;
int *ary[2];
ary[0] = &i;
ary[1] = &j;
printf("%d\n", ary[0][1]);
}
a) 10
b) 2
c) Compile time error
d) Undefined behaviour
View Answer
Explanation: None.
6. What is the output of this C code?
#include <stdio.h>
int main()
{
int ary[2][3][4], j = 20;
ary[0][0] = &j;
printf("%d\n", *ary[0][0]);
}
a) Compile time error
b) 20
c) Address of j
d) Undefined behaviour
View Answer
Explanation: None.
7. What is the output of this C code?
#include <stdio.h>
int main()
{
int ary[2][3];
ary[][] = {{1, 2, 3}, {4, 5, 6}};
printf("%d\n", ary[1][0]);
}
a) Compile time error
b) 4
c) 1
d) 2
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
Here’s the list of Best Reference Books in C Programming Language.
To practice all features of C programming language, here is complete set of 1000+ Multiple Choice Questions and Answers on C.