When memory would be assigned for the array
short x[5];
Memory requirement = $5*2B=10B$
And for
union {
float y;
long z;
}
Memory requirement = $8B$ because the size of a union is the size of it's largest data member.
Hence, total memory requirements = $18B$
Option C
Let's consider memory alignment now.
If machine architecture has word size = 32 bits, then every piece of addressable memory must be in multiples of a word. Or equivalently 32 bits. Or, equivalently 4B.
Hence for:
short x[5];
Memory requirement = $5*2B=10B$ $+2B$ of padding = $12B$ (Multiple of 4B)
for:
union {
Memory requirement = $8B$
So, total = $20B$
If machine architecture has word size = 64 bits, then every piece of addressable memory must be in multiples of a word. Or equivalently 64 bits. Or, equivalently 8B.
Hence for:
short x[5];
Memory requirement = $5*2B=10B$ $+6B$ of padding = $16B$ (Multiple of 8B)
for:
union {
Memory requirement = $8B$
So, total = $24B$