Top

Discussion

Union differs from structure in the following way

  • A.All members are used at a time
  • B.Only one member can be used at a time
  • C.Union cannot have more members
  • D.Union initialized all members as structure

Answer: B

When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater than or equal to the sum of sizes of its members. The smaller members may end with unused slack bytes. While in case of Union when a variable is associated with a union, the compiler allocates the memory by considering the size of the largest memory. So, size of union is equal to the size of largest member.

No comment is present. Be the first to comment.
Loading…

Post your comment