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.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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.

Sudha said:   1 decade ago
Union have a same memory space in all the variable. But structure in different size to access the variables.

Vinay said:   1 decade ago
Union elements can be of different sizes, however they share the same space of memory.

Kona durga prasad said:   1 decade ago
In union can access one data member at time because union are different sizes.

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.

Post your comments here:

Your comments will be displayed after verification.