What is the difference between a structure and a union in C?

19 views
  • A structure is a collection of variables of different types, while a union is a collection of variables of the same type. (Correct Answer)
  • A structure is a collection of variables of the same type, while a union is a collection of variables of different types.
  • A structure and a union are the same thing in C.
  • There is no difference between a structure and a union in C.

Explanation

Correct answer: a) A structure is a collection of variables of different types, while a union is a collection of variables of the same type.

Explanation: In C, a structure is a collection of variables of different types, while a union is a collection of variables of the same type. The memory allocated for a union is only enough to hold the largest member of the union.

Comments (0)

No comments yet. Be the first to comment!

Want to practice more?

Explore thousands of MCQs across every exam category on Exams Nepal.

Find More MCQs