Answer & Solution
Employee
structure consists of three members: an integer id
, an array of characters name
of size 20, and a float salary
.The size of an integer is typically 4 bytes, the size of a float is also typically 4 bytes, and the size of each character in the array depends on the character set being used (usually 1 byte per character). However, due to memory alignment requirements, additional padding may be added after the
name
array to ensure proper alignment of subsequent members.So, the calculation of the structure size would be:
int id
: 4 byteschar name[20]
: 20 bytesPadding to align
salary
to the next 4-byte boundary (assuming 4-byte alignment)float salary
: 4 bytesTotal: 4 bytes (id) + 20 bytes (name) + 4 bytes (padding) + 4 bytes (salary) = 32 bytes.
Therefore, the correct answer is Option D: 32 bytes.