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

Q221.
What is the output of this program?
#include <stdio.h>
 struct 
{
 int i;
 float ft;
}decl;
int main(){
    decl.i = 4;
 decl.ft = 7.96623;
 printf("%d %.2f", decl.i, decl.ft);
 return 0;
}
Discuss
Answer: (a).4 7.97
Q222.
What is the output of this program?
void main()
  {
  struct bitfields {
  int bits_1: 2;
  int bits_2: 9;
  int bits_3: 6;
  int bits_4: 1;
  }bit;
  printf("%d", sizeof(bit));
}

a.

2

b.

3

c.

4

d.

0

Discuss
Answer: (b).3
Q223.
What is the output of this program?
#include <stdio.h>
int main(){
    struct leader
 {
 char *lead;
 int born;
 };
 struct leader l1 = {"AbdulKalam", 1931};
 struct leader l2 = l1;
 printf("%s %d", l2.lead, l1.born);
}
Discuss
Answer: (c).AbdulKalam 1931
Q224.
What is the output of this program?
#include <stdio.h>
struct employee
{
  char *empname;
  int salary;
};
int main()
{
  struct employee e, e1;
  e.empname = "Sridhar";
  e1 = e;
  printf("%s %s", e.empname, e1.empname);
  return 0;
}
Discuss
Answer: (c).Sridhar Sridhar
Q225.
What is the output of this program?
#include <stdio.h>
struct student
{
  int no = 5;
  char name[20];
};
void main()
{
  struct student s;
  s.no = 8;
  printf("hello");
}
Discuss
Answer: (b).Compile time error
Q226.
What is the output of this program?
#include <stdio.h>
void main()
{
  struct number
  {
    int no;
    char name[20];
  };
  struct number s;
  s.no = 50;
  printf("%d", s.no);
}
Discuss
Answer: (d).50
Q227.
Number of bytes in memory taken by the below structure is

#include <stdio.h>
struct test
{
  int k;
  char c;
};
Discuss
Answer: (a).Multiple of integer size
Q228.
What is the output of this program?
#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
Q229.
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;
Q230.
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 above

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!