Union is also a data structure just like structure which can store multiple variables of different type. But only difference is that in case of union memory is allocated only for the largest data member and shared by other data member also. It means same memory is shared by all the variables of union.
Declaration of union
tag define the name of union and members are the elements of union tag.
union declaration example
above declaration declare a union of name test. which has two member integer a and b.
to create a single variable of type union below is the syntax
union tag variable_name;
union test x;
access union members
Union member can be accessed by (.) operator between the name of union variable and the member name.