Units

### Unit: Arrays Of Structures - Questions and Answers

Practice these Arrays Of Structures 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 Arrays Of Structures for following purpose.

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

1.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct point`
3. `    {`
4. `        int x;`
5. `        int y;`
6. `    };`
7. `    void foo(struct point*);`
8. `    int main()`
9. `    {`
10. `        struct point p1[] = {1, 2, 3, 4, 5};`
11. `        foo(p1);`
12. `    }`
13. `    void foo(struct point p[])`
14. `    {`
15. `        printf("%d %d\n", p->x, (p + 2).y);`
16. `    }`

Explanation:

2.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct student`
3. `    {`
4. `        char *c;`
5. `    };`
6. `    void main()`
7. `    {`
8. `        struct student s[2];`
9. `        printf("%d", sizeof(s));`
10. `    }`

Explanation:

3.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct point`
3. `    {`
4. `        int x;`
5. `        int y;`
6. `    };`
7. `    void foo(struct point*);`
8. `    int main()`
9. `    {`
10. `        struct point p1[] = {1, 2, 3, 4};`
11. `        foo(p1);`
12. `    }`
13. `    void foo(struct point p[])`
14. `    {`
15. `        printf("%d\n", p->x);`
16. `    }`

Explanation:

4.

What is the correct syntax to declare a function foo() which receives an array of structure in     function?

Explanation:

5.

The correct syntax to access the member of the ith structure in the array of structures is?

``` Assuming: struct temp
{
int b;
}s[50];```

Explanation:

6.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct student`
3. `    {`
4. `        char *name;`
5. `    };`
6. `    struct student s[2];`
7. `    void main()`
8. `    {`
9. `        s[0].name = "alan";`
10. `        s[1] = s[0];`
11. `        printf("%s%s", s[0].name, s[1].name);`
12. `        s[1].name = "turing";`
13. `        printf("%s%s", s[0].name, s[1].name);`
14. `    }`

Explanation:

7.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct student`
3. `    {`
4. `        char *name;`
5. `    };`
6. `    struct student s[2], r[2];`
7. `    void main()`
8. `    {`
9. `        s[0].name = "alan";`
10. `        s[1] = s[0];`
11. `        r = s;`
12. `        printf("%s%s", r[0].name, r[1].name);`
13. `    }`

Explanation:

8.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct point`
3. `    {`
4. `        int x;`
5. `        int y;`
6. `    };`
7. `    void foo(struct point*);`
8. `    int main()`
9. `    {`
10. `        struct point p1[] = {1, 2, 3, 4, 5};`
11. `        foo(p1);`
12. `    }`
13. `    void foo(struct point p[])`
14. `    {`
15. `        printf("%d %d\n", p->x, (p + 2)->y);`
16. `    }`

Explanation:

9.

What is the output of this C code?
(Assuming size of int be 4)

1. `    #include <stdio.h>`
2. `    struct temp`
3. `    {`
4. `        int a;`
5. `        int b;`
6. `        int c;`
7. `    } p[] = {0};`
8. `    main()`
9. `    {`
10. `        printf("%d", sizeof(p));`
11. `    }`

Explanation:

10.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct point`
3. `    {`
4. `        int x;`
5. `        int y;`
6. `    };`
7. `    void foo(struct point*);`
8. `    int main()`
9. `    {`
10. `        struct point p1[] = {1, 2, 3, 4};`
11. `        foo(p1);`
12. `    }`
13. `    void foo(struct point p[])`
14. `    {`
15. `        printf("%d %d\n", p->x, ++p->x);`
16. `    }`

Explanation:

11.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct student`
3. `    {`
4. `    };`
5. `    void main()`
6. `    {`
7. `        struct student s[2];`
8. `        printf("%d", sizeof(s));`
9. `    }`

Explanation:

12.

Which of the following uses structure?

Explanation:

13.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct student`
3. `    {`
4. `        char *name;`
5. `    };`
6. `    void main()`
7. `    {`
8. `        struct student s[2], r[2];`
9. `        s[1] = s[0] = "alan";`
10. `        printf("%s%s", s[0].name, s[1].name);`
11. `    }`

Explanation:

14.

Comment on the output of this C code?

1. `    #include <stdio.h>`
2. `    struct temp`
3. `    {`
4. `        int a;`
5. `        int b;`
6. `        int c;`
7. `    };`
8. `    main()`
9. `    {`
10. `        struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};`
11. `    }`

Explanation:

15.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct point`
3. `    {`
4. `        int x;`
5. `        int y;`
6. `    };`
7. `    void foo(struct point*);`
8. `    int main()`
9. `    {`
10. `        struct point p1[]  =  {1, 2, 3, 4};`
11. `        foo(p1);`
12. `    }`
13. `    void foo(struct point p[])`
14. `    {`
15. `        printf("%d\n", p[1].x);`
16. `    }`