Units

### Unit: Multidimensional Arrays - Questions and Answers

Practice these Multidimensional Arrays under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Multidimensional Arrays for following purpose.

– Anyone who is wishing to increase their perfect knowledge of Multidimensional Arrays of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically  Multidimensional Arrays.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Multidimensional Arrays under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of   Multidimensional Arrays topic of C Programming:

1.

What is the output of this C code?

1. `    #include <stdio.h>`
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. `    }`

Explanation:

2.

Applications of multidimensional array are?

Explanation:

3.

What is the output of this C code?

1. `    #include <stdio.h>`
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("%d\n", ary[0][1]);`
13. `    }`

Explanation:

4.

What is the output of this C code?

1. `    #include <stdio.h>`
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. `    }`

Explanation:

5.

What is the output of this C code?

1. `    #include <stdio.h>`
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. `    }`

Explanation:

6.

What is the output of this C code?

1. `    #include <stdio.h>`
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("%d\n", *ary[k]);`
15. `    }`

Explanation:

7.

Comment on the following statement:
int (*a)[7];

Explanation:

8.

What is the correct syntax to send a 3-dimensional array as a parameter?
(Assuming declaration int a[5][4][3];)

Explanation:

9.

Which of the following is not possible statically in C?

Explanation:

10.

What is the output of this C code?

1. `    #include <stdio.h>`
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. `    }`

Explanation:

11.

What is the output of this C code?

1. `    #include <stdio.h>`
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. `    }`

Explanation:

12.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        int ary[2][3];`
5. `        ary[][] = {{1, 2, 3}, {4, 5, 6}};`
6. `        printf("%d\n", ary[1][0]);`
7. `    }`

Explanation:

13.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        int ary[2][3][4], j = 20;`
5. `        ary[0][0] = &j;`
6. `        printf("%d\n", *ary[0][0]);`
7. `    }`

Explanation:

14.

Comment on the 2 arrays regarding P and Q:

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

Explanation:

15.

What is the output of this C code?

1. `    #include <stdio.h>`
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("%d\n", *ary[k]);`
14. `    }`