C-Structure & Union Question and Answer

C-Structure & Union Question and Answer
61. Find the output
union xxx
{
int x;
float y;
char z;
};
void main ( )
{
union xxx abc;
abc.x=10;
abc.y=3.14;
printf("%d", abc.x);

  • 10
  • 3.14
  • Garbage value
  • Compilation error
Show Answer
62. Find the output
union abc
{
int a;
long b;
};
void main ( )
{
union abc x;
x. b=10;
printf("%1d %d", x.b);
}

  • 10 10
  • 10 Garbage value
  • Garbage value 10
  • Compilation error
Show Answer
63. Which of the following is flse regarding bit fields?
  • Bit fields may share a storage unit with other structure members
  • Bit fields must entirely reside in a storage unit of its appropriate type.
  • Bit fields only applicable to unsigned integral but not signed integral.
  • Bit fields are used to construct the protocol header fields.
Show Answer
64. Which of the following is best suited for memory optimization
  • Union
  • Self referential structure
  • Array
  • Linked list
Show Answer
65. Very first member of union is known as
  • smart member
  • Lical member
  • Data member
  • Active member
Show Answer
66. Union is
  • A special jtype of structure
  • A pointerdata type
  • A function data type
  • Not a data type
Show Answer
67. Find the output
union xyz
float f;
int i;
} xx=5.0;
void main ( )
{
printf ('%f %d", xx.f, xx.i);
}

  • 5.0000 0
  • 5.0000 Garbage
  • Garbage garbage
  • Compilation Error
Show Answer
68. Which of the following statements true regarding UNION ?
I. Self-referential structure may be used as member of union.
II. Niested union is also possible.
III. ONe member of a union active at a time.
IV. Only active member can be initialized.
  • III & IV
  • II, III & IV
  • I, II & III
  • All of these
Show Answer
69. Find the output
union usa
{
unsigned int x[2];
char ch[4];
}
canada;
void main ( )
{
strcpy (canada.ch, "xyz"));
printf('%s%d", canada. ch, canada.x[1]);
}

  • Error: Library function not allowed initializing union member.
  • xyz 120
  • xyz 121
  • xyz 122
Show Answer
70. The main advantage of union over structure is
  • Memory mapping
  • Memory utilization
  • Memory optimization
  • Memory leak
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test