C | Structure & Union | Question 7
Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed.
(D) Compiler Error
Explanation: When we declare a union, memory allocated for a union variable of the type is equal to memory needed for the largest member of it, and all members share this same memory space. In above example, “char arr” is the largest member. Therefore size of union test is 8 bytes.
Quiz of this Question