
406 Programming and Data Structures
{
ctoar nattfttfSJ;
in t age;
union r e s u lt p e r f;
} data;
c lrs c r O ;
printf ("Size of union; %d\n",$izeof(data.perf));
printf ("Size of Structure: %d\n", sizeoffdata));
i
Q.UXBJI;
Size of union: 2
Size of Structure : 19
Explanation Union contains two variables of data types in t & char respectively. The in t &
char requires 2 & 1 bytes respectively for storage. According to the theory the union reserves two
bytes because in t takes more space than char data type.
The structure res are defined immediately after union, which contains data type ch ar, i n t , &
union variable. The size of s