C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - True / False Questions (Q.No. 8)
8.
Union elements can be of different sizes.
Discussion:
6 comments Page 1 of 1.
SHRIKANTH said:
4 years ago
I think we can make union elements to have different sizes using bit fields.
Ex:
union a
{
int data;
char ele:1;
}
;char take 1 byte and int takes 2 bytes.
So the answer is True.
Ex:
union a
{
int data;
char ele:1;
}
;char take 1 byte and int takes 2 bytes.
So the answer is True.
Shub said:
5 years ago
Didn't understand can someone explain with an example?
Sudarsana said:
8 years ago
Yes, it takes as highest memory space.
Sudha said:
1 decade ago
Union have a same memory space in all the variable. But structure in different size to access the variables.
Kona durga prasad said:
1 decade ago
In union can access one data member at time because union are different sizes.
Vinay said:
1 decade ago
Union elements can be of different sizes, however they share the same space of memory.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers