Units

### Unit: Pointers Vs. Multi-dimensional Arrays - Questions and Answers

Practice these Pointers Vs. Multi-dimensional 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 Pointers Vs. Multi-dimensional Arrays for following purpose.

– Anyone who is wishing to increase their perfect knowledge of Pointers Vs. Multi-dimensional Arrays of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Pointers Vs. Multi-dimensional 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 Pointers Vs. Multi-dimensional 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  Pointers Vs. Multi-dimensional Arrays topic of C Programming:

1.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        char a[2][6] = {"hello", "hi"};`
5. `        printf("%d", sizeof(a));`
6. `        return 0;`
7. `    }`

Explanation:

2.

int *b[10]; which is true for b

Explanation:

3.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        char *a[2] = {"hello", "hi"};`
5. `        printf("%s", *(a + 1));`
6. `        return 0;`
7. `    }`

Explanation:

4.

What is the output of the code given below?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        char a[1][5] = {"hello"};`
5. `        printf("%s", a[0]);`
6. `        return 0;`
7. `    }`

Explanation:

5.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    void main()`
3. `    {`
4. `        char a[10][5] = {"hi", "hello", "fellows"};`
5. `        printf("%d", sizeof(a[1]));`
6. `    }`

Explanation:

6.

Which of the following statements are true?
P. Pointer to Array
Q. Multi-dimensional array

Explanation:

7.

Comment on the following two operations?
int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
int b[][] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 2

Explanation:

8.

int a[10][20]; which is true for a

Explanation:

9.

What is the output of the code given below?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        char *a[1] = {"hello"};`
5. `        printf("%s", a[0]);`
6. `        return 0;`
7. `    }`

Explanation:

10.

What is the output of this C code (considering sizeof char is 1 and pointer is 4)?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        char *a[2] = {"hello", "hi"};`
5. `        printf("%d", sizeof(a));`
6. `        return 0;`
7. `    }`

Explanation:

11.

Advantage of a multi-dimension array over pointer array.

Explanation:

12.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    int main()`
3. `    {`
4. `        char a[2][6] = {"hello", "hi"};`
5. `        printf("%s", *a + 1);`
6. `        return 0;`
7. `    }`

Explanation:

13.

Comment on the following two operations?
int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1
int b[4][4] = {{1, 2, 3}, {1, 2, 3, 4}};//- 2

Explanation:

14.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    void main()`
3. `    {`
4. `        char a[10][5] = {"hi", "hello", "fellows"};`
5. `        printf("%p\n", a);`
6. `        printf("%p", a[0]);`
7. `    }`