This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Multidimensional Arrays – 2”.
Pre-requisite for C Multidimensional Arrays MCQ set: Video Tutorial on 3-Dimensional Arrays.
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. 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
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
void foo(int *ary[]);
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 will be the output of the following C code?
#include <stdio.h>
void foo(int (*ary)[3]);
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 will be the output of the following C code?
#include <stdio.h>
int main()
{
foo(ary);
}
void foo(int **ary)
{
int i = 10, k = 20, j = 30;
int *ary[2];
ary[0] = &i;
ary[1] = &j;
printf("%d\n", ary[0][1]);
}
a) 10
b) 20
c) Compile time error
d) Undefined behaviour
View Answer
Explanation: None.
6. What will be the output of the following 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 will be the output of the following 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.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check C Books
- Apply for C Internship
- Practice BCA MCQs
- Apply for Computer Science Internship
- Practice Computer Science MCQs