Knowee
Questions
Features
Study Tools

Unions What is the size of the following union. Assume that the size of int is 2, size of float is 4 and size of char is 1. #include <stdio.h> union tag { int a; float b; char c; };

Question

Unions What is the size of the following union. Assume that the size of int is 2, size of float is 4 and size of char is 1. #include <stdio.h> union tag { int a; float b; char c; };

🧐 Not the exact question you are looking for?Go ask a question

Solution

The size of a union in C is determined by the size of the largest member in the union. In this case, the members of the union are int, float, and char. Given the sizes provided:

  • The size of int a is 2 bytes.
  • The size of float b is 4 bytes.
  • The size of char c is 1 byte.

Since the size of the union is determined by the largest member, the size of the union 'tag' is 4 bytes (the size of the float 'b').

This problem has been solved

Similar Questions

Unions What is the size of the following union. Assume that the size of int is 2, size of float is 4 and size of char is 1. #include <stdio.h> union tag { int a; float b; char c; };

What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)

The size of a union is determined by the size of the __________

Multi Choice Type QuestionWhat determines the size of a union in C?Marks : 1Negative Marks : 0Answer hereThe biggest member in the unionThe sum of the sizes of all membersThe first member in the unionThe last member in the union

The size of a union is determined by the size of the __________First member in the unionLast member in the unionBiggest member in the unionSum of the sizes of all members

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.