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 6 of 27

Q51.
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: (b).1 0
Q52.
What is the output of this C code?
#include <stdio.h>
    struct student
    {
        char *c;
    };
    void main()
    {
        struct student s[2];
        printf("%d", sizeof(s));
    }

a.

2

b.

4

c.

16

d.

8

Discuss
Answer: (d).8
Q53.
What is the output of this C code?
#include <stdio.h>
    struct p
    {
        int x;
        char y;
    };
    int main()
    {
        struct p p1[] = {1, 92, 3, 94, 5, 96};
        struct p *ptr1 = p1;
        int x = (sizeof(p1) / 3);
        if (x == sizeof(int) + sizeof(char))
            printf("%d\n", ptr1->x);
        else
            printf("falsen");
    }
Discuss
Answer: (d).false
Q54.
What is the output of this C code?
#include <stdio.h>
    struct p
    {
        int x;
        char y;
    };
    int main()
    {
        struct p p1[] = {1, 92, 3, 94, 5, 96};
        struct p *ptr1 = p1;
        int x = (sizeof(p1) / sizeof(ptr1));
        if (x == 1)
            printf("%d\n", ptr1->x);
        else
            printf("false\n");
    }
Discuss
Answer: (c).false
Q55.
What is the output of this C code?
#include <stdio.h>
    struct p
    {
        int x;
        char y;
    };
    typedef struct p* q*;
    int main()
    {
        struct p p1[] = {1, 92, 3, 94, 5, 96};
        q ptr1 = p1;
        printf("%d\n", ptr1->x);
    }
Discuss
Answer: (a).Compile time error
Q56.
What is the output of this C code?
#include <stdio.h>
    struct p
    {
        int x;
        char y;
    };
    void foo(struct p* );
    int main()
    {
        typedef struct p* q;
        struct p p1[] = {1, 92, 3, 94, 5, 96};
        foo(p1);
    }
    void foo(struct p* p1)
    {
        q ptr1 = p1;
        printf("%d\n", ptr1->x);
    }
Discuss
Answer: (a).Compile time error
Q57.
Which of the following are incorrect syntax for pointer to structure?
(Assuming struct temp{int b;}*my_struct;)
Discuss
Answer: (a).*my_struct.b = 10;
Q58.
Which of the following is an incorrect syntax to pass by reference a member of a structure in a function?
(Assume: struct temp{int a;}s;)
Discuss
Answer: (d).none of the mentioned
Q59.
For the following function call which option is not possible?
func(&s.a); //where s is a variable of type struct and a is the member of the struct.
Discuss
Answer: (a).Compiler can access entire structure from the function
Q60.
Comment on the output of this C code?
#include <stdio.h>
    struct temp
    {
        int a;
    } s;
    void change(struct temp);
    main()
    {
        s.a = 10;
        change(s);
        printf("%d\n", s.a);
    }
    void change(struct temp s)
    {
        s.a = 1;
    }
Discuss
Answer: (b).Output will be 10
Page 6 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!