Units

### Unit: Structures And Functions - Questions and Answers

Practice these Structures And Functions 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 Structures And Functions for following purpose.

– Anyone who is wishing to increase their perfect knowledge of Structures And Functions of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Structures And Functions.
– 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 Structures And Functions 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  Structures And Functions 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. `    struct notpoint`
8. `    {`
9. `        int x;`
10. `        int y;`
11. `    };`
12. `    int main()`
13. `    {`
14. `        struct point p = {1};`
15. `        struct notpoint p1 = p;`
16. `        printf("%d\n", p1.x);`
17. `    }`

Explanation:

2.

What’s the output of the following code?

1. `    #include <stdio.h>`
2. `    struct temp`
3. `    {`
4. `        int a;`
5. `    } s;`
6. `    void func(struct temp)`
7. `    {`
8. `        s.a = 10;`
9. `        printf("%d\t", s.a); s`
10. `    }`
11. `    main()`
12. `    {`
13. `        func(s);`
14. `        printf("%d\t", s.a);`
15. `    }`

Explanation:

3.

Which of the following is not possible under any scenario?

Explanation:

4.

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, m;`
9. `        s.name = "st";`
10. `        m = s;`
11. `        printf("%s%s", s.name, m.name);`
12. `    }`

Explanation:

5.

The output of the code below is

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

Explanation:

6.

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};`
11. `        foo(&p1);`
12. `    }`
13. `    void foo(struct point *p)`
14. `    {`
15. `        printf("%d\n", *p->x++);`
16. `    }`

Explanation:

7.

What is the output of this C code?

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

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. `    struct notpoint`
8. `    {`
9. `        int x;`
10. `        int y;`
11. `    };`
12. `    struct point foo();`
13. `    int main()`
14. `    {`
15. `        struct point p = {1};`
16. `        struct notpoint p1 = {2, 3};`
17. `        p1 = foo();`
18. `        printf("%d\n", p1.x);`
19. `    }`
20. `    struct point foo()`
21. `    {`
22. `        struct point temp = {1, 2};`
23. `        return temp;`
24. `    }`

Explanation:

9.

What is the output of this C code?

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

Explanation:

10.

Which of the following operation is illegal in structures?

Explanation:

11.

Which of the following return-type cannot be used for a function in C?

Explanation:

12.

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};`
11. `        foo(&p1);`
12. `    }`
13. `    void foo(struct point *p)`
14. `    {`
15. `        printf("%d\n", *p.x++);`
16. `    }`

Explanation:

13.

What is the output of this C code?

1. `    #include <stdio.h>`
2. `    struct student`
3. `    {`
4. `        char *name;`
5. `    };`
6. `    struct student s;`
7. `    struct student fun(void)`
8. `    {`
9. `        s.name = "newton";`
10. `        printf("%s\n", s.name);`
11. `        s.name = "alan";`
12. `        return s;`
13. `    }`
14. `    void main()`
15. `    {`
16. `        struct student m = fun();`
17. `        printf("%s\n", m.name);`
18. `        m.name = "turing";`
19. `        printf("%s\n", s.name);`
20. `    }`

Explanation:

14.

What is the output of this C code?

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

Explanation:

15.

Presence of code like “s.t.b = 10” indicate.