Union In C Programming With Example-99webcode
#include<stdio.h>
union student
{
int a;
int b;
float marks;
};
void main()
{
union student s1;
s1.a=10;
s1.b=21;
s1.marks=88.25;
printf("%d\n",s1.a); //1118863360
printf("%d\n",s1.b);//1118863360
printf("%f\n",s1.marks); //88.250000
printf("%d\n",sizeof(s1)); //4
}
output:
1118863360
1118863360
88.250000
4