adplus-dvertising

Welcome to the Structures and Unions MCQs Page

Dive deep into the fascinating world of Structures and Unions with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Structures and Unions, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Structures and Unions, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Structures and Unions. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Structures and Unions. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Structures and Unions MCQs | Page 5 of 27

Q41.
What is the output of this C code?
#include <stdio.h>
    struct student
    {
        char *name;
    };
    struct student s[2];
    void main()
    {
        s[0].name = "alan";
        s[1] = s[0];
        printf("%s%s", s[0].name, s[1].name);
        s[1].name = "turing";
        printf("%s%s", s[0].name, s[1].name);
    }
Discuss
Answer: (a).alan alan alan turing
Q42.
What is the output of this C code?
#include <stdio.h>
    struct student
    {
        char *name;
    };
    struct student s[2], r[2];
    void main()
    {
        s[0].name = "alan";
        s[1] = s[0];
        r = s;
        printf("%s%s", r[0].name, r[1].name);
    }
Discuss
Answer: (b).Compile time error
Q43.
What is the output of this C code?
#include <stdio.h>
    struct student
    {
        char *name;
    };
    void main()
    {
        struct student s[2], r[2];
        s[1] = s[0] = "alan";
        printf("%s%s", s[0].name, s[1].name);
    }
Discuss
Answer: (c).Compile time error
Q44.
What is the output of this C code?
#include <stdio.h>
    struct student
    {
    };
    void main()
    {
        struct student s[2];
        printf("%d", sizeof(s));
    }

a.

2

b.

4

c.

8

d.

0

Discuss
Answer: (d).0
Q45.
What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    void foo(struct point*);
    int main()
    {
        struct point p1[]  =  {1, 2, 3, 4};
        foo(p1);
    }
    void foo(struct point p[])
    {
        printf("%d\n", p[1].x);
    }
Discuss
Answer: (b).3
Q46.
What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    void foo(struct point*);
    int main()
    {
        struct point p1[] = {1, 2, 3, 4};
        foo(p1);
    }
    void foo(struct point p[])
    {
        printf("%d\n", p->x);
    }
Discuss
Answer: (a).1
Q47.
What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    void foo(struct point*);
    int main()
    {
        struct point p1[] = {1, 2, 3, 4};
        foo(p1);
    }
    void foo(struct point p[])
    {
        printf("%d %d\n", p->x, ++p->x);
    }
Discuss
Answer: (b).2 2
Q48.
What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    } p[] = {1, 2, 3, 4, 5};
    void foo(struct point*);
    int main()
    {
        foo(p);
    }
    void foo(struct point p[])
    {
        printf("%d %d\n", p->x, p[2].y);
    }
Discuss
Answer: (a).1 0
Q49.
What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    void foo(struct point*);
    int main()
    {
        struct point p1[] = {1, 2, 3, 4, 5};
        foo(p1);
    }
    void foo(struct point p[])
    {
        printf("%d %d\n", p->x, p[3].y);
    }
Discuss
Answer: (c).1 somegarbagevalue
Q50.
What is the output of this C code?
#include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    void foo(struct point*);
    int main()
    {
        struct point p1[] = {1, 2, 3, 4, 5};
        foo(p1);
    }
    void foo(struct point p[])
    {
        printf("%d %d\n", p->x, (p + 2).y);
    }
Discuss
Answer: (a).Compile time error
Page 5 of 27

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!