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);
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
62. Find the output
union abc
{
int a;
long b;
};
void main ( )
{
union abc x;
x. b=10;
printf("%1d %d", x.b);
}
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
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.
64. Which of the following is best suited for memory optimization
- Union
- Self referential structure
- Array
- Linked list
65. Very first member of union is known as
- smart member
- Lical member
- Data member
- Active member
66. Union is
- A special jtype of structure
- A pointerdata type
- A function data type
- Not a data type
67. Find the output
union xyz
float f;
int i;
} xx=5.0;
void main ( )
{
printf ('%f %d", xx.f, xx.i);
}
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
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.
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
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]);
}
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
70. The main advantage of union over structure is
- Memory mapping
- Memory utilization
- Memory optimization
- Memory leak