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

Explore more Topics under C Programming

Q181.
Point out the error in the program in 16-bit platform?
#include<stdio.h>

int main()
{
    struct bits
    {
        int i:40;
    }bit;

    printf("%d\n", sizeof(bit));
    return 0;
}
Discuss
Answer: (c).Error: Bit field too large
Q182.
Point out the error in the program?
#include<stdio.h>

int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a z1 = {512};
    union a z2 = {0, 2};
    return 0;
}
Discuss
Answer: (b).Error: in Initializing z2
Q183.
Point out the error in the program?
#include<stdio.h>

int main()
{
    struct emp
    {
        char n[20];
        int age;
    };
    struct emp e1 = {"Dravid", 23};
    struct emp e2 = e1;
    if(e1 == e2)
        printf("The structure are equal");
    return 0;
}
Discuss
Answer: (b).Error: Structure cannot be compared using '=='
Q184.
Point out the error in the program?
#include<stdio.h>

int main()
{
    struct bits
    {
        float f:2;
    }bit;

    printf("%d\n", sizeof(bit));
    return 0;
}
Discuss
Answer: (c).Error: cannot set bit field for float
Q185.
Point out the error in the program?
#include<stdio.h>

int main()
{
    struct emp
    {
        char name[25];
        int age;
        float bs;
    };
    struct emp e;
    e.name = "Suresh";
    e.age = 25;
    printf("%s %d\n", e.name, e.age);
    return 0;
}
Discuss
Answer: (a).Error: Lvalue required/incompatible types in assignment
Q186.
Which of the following statements correct about the below program?
#include<stdio.h>

int main()
{
    struct emp
    {
        char name[25];
        int age;
        float sal;
    };
    struct emp e[2];
    int i=0;
    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, &e[i].age, &e[i].sal);

    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, e[i].age, e[i].sal);
    return 0;
}
Discuss
Answer: (c).Error: Floating point formats not linked Abnormal program termination.
Q187.
Which of the following statements correct about the below program?
#include<stdio.h>

int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a u1 = {512};
    union a u2 = {0, 2};
    return 0;
}



1:
u2 CANNOT be initialized as shown.


2:
u1 can be initialized as shown.


3:
To initialize char ch[] of u2 '.' operator should be used.


4:
The code causes an error 'Declaration syntax error'
Discuss
Answer: (c).1, 2, 3
Q188.
Which of the following statements correctly assigns 12 to month using pointer variable pdt?
#include<stdio.h>

    struct date
    {
        int day;
        int month;
        int year;
    };
int main()
{
    struct date d;
    struct date *pdt;
    pdt = &d;
    return 0;
}
Discuss
Answer: (d).pdt->month = 12
Discuss
Answer: (b).Structure engine is nested within structure maruti.
Q190.
Consider the declaration. Here v occupies
static struct
          {    unsigned a:5;
               unsigned b:5;
               unsigned c:5;
             unsigned d:5%:
              }v=(1,2,3,4);
Discuss
Answer: (a).4 bytes

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!