Units

### Unit: Pointers And Arrays - Questions and Answers

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

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

1.

What is the output of this C code?

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

Explanation:

2.

An array of similar data types which themselves are collection of dissimilar data type are

Explanation:

3.

Comment on an array of void data type:

Explanation:

4.

What is the output of the code given below?

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

Explanation:

5.

What is the output of the code given below?

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

Explanation:

6.

What is the output of the code given below?

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

Explanation:

7.

What is the output of the code given below?

1. `    #include <stdio.h>`
2. `    void foo( int[] );`
3. `    int main()`
4. `    {`
5. `        int ary[4] = {1, 2, 3, 4};`
6. `        foo(ary);`
7. `        printf("%d ", ary[0]);`
8. `    }`
9. `    void foo(int p[4])`
10. `    {`
11. `        int i = 10;`
12. `        p = &i;`
13. `        printf("%d ", p[0]);`
14. `    }`

Explanation:

8.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    void main()`
3. `    {`
4. `        char *s = "hello";`
5. `        char *p = s;`
6. `        printf("%p\t%p", p, s);`
7. `    }`

Explanation:

9.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    void main()`
3. `    {`
4. `        int a[3] = {1, 2, 3};`
5. `        int *p = a;`
6. `        printf("%p\t%p", p, a);`
7. `    }`

Explanation:

10.

Different ways to initialize an array with all elements as zero are

Explanation:

11.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    void main()`
3. `    {`
4. `        char *s= "hello";`
5. `        char *p = s;`
6. `        printf("%c\t%c", 1[p], s[1]);`
7. `    }`

Explanation:

12.

What is the output of this C code?

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

Explanation:

13.

What is the output of this C code?

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

Explanation:

14.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    void main()`
3. `    {`
4. `        char *s= "hello";`
5. `        char *p = s;`
6. `        printf("%c\t%c", *(p + 3),  s[1]);`
7. `    }`