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

Explore more Topics under C Programming

Q151.
What is the output of this C code?
#include <stdio.h>
    struct p
    {
        unsigned int x : 1;
        unsigned int y : 1;
    };
    int main()
    {
        struct p p;
        p.x = 1;
        p.y = 2;
        printf("%d\n", p.y);
    }
Discuss
Answer: (c).0
Q152.
Determine Output:
void main()
{
      struct xx
      {
            int x=3;
            char name[] = "hello";
      };
      struct xx *s = malloc(sizeof(struct xx));
      printf("%d", s->x);
      printf("%s", s->name); 
}
Discuss
Answer: (b).Compiler Error
Q153.
Determine output:
void main()
{
      extern int i;
      i=20;
      printf("%d", sizeof(i));
}
Discuss
Answer: (d).Linker Error
Q154.
What is the output of the program?
#include<stdio.h>
int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a u;
    u.ch[0] = 3;
    u.ch[1] = 2;
    printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
    return 0;
}
Discuss
Answer: (a).3, 2, 515
Q155.
Point out the error in the following program.
#include<stdio.h>
struct emp
{
    char name[20];
    int age;
};
int main()
{
    emp int xx;
    int a;
    printf("%d\n", &a);
    return 0;
}
Discuss
Answer: (b).Error: in emp int xx;
Q156.
Which of the following is correct about err used in the declaration given below?
typedef enum error { warning, test, exception } err;
Discuss
Answer: (a).It is a typedef for enum error
Q157.
Which of the structure is incorrcet?
1 :	
struct aa
{
    int a;
    float b;
};

2 :	
struct aa
{
    int a;
    float b;
    struct aa var;
};

3 :	
struct aa
{
    int a;
    float b;
    struct aa *var;
};
Discuss
Answer: (b).2
Q158.
Which of the structure is correct?
1 :	
struct book
{
    char name[10];
    float price;
    int pages;
};

2 :	
struct aa
{
    char name[10];
    float price;
    int pages;
}

3 :	
struct aa
{
    char name[10];
    float price;
    int pages;
}
Discuss
Answer: (a).1
Q159.
Which of the following declarations are correct ?

1 : typedef long a;
extern int a c;
2 : typedef long a;
extern a int c;
3 : typedef long a;
extern a c;
Discuss
Answer: (c).3 correct
Q160.
How will you free the allocated memory ?
Discuss
Answer: (b).free(var-name);

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!