//Program to show the concept of union.
#include<stdio.h>
#include<conio.h>
void main()
{
union student
{
char g;
int r;
float m;
double f;
}s;
clrscr();
printf("size of union %d",sizeof(s));
printf("\n enter the grade");
s.g=getche();
printf("\n the grade %c",s.g);
printf("\n enter the rollno");
scanf("%d",&s.r);
printf("\n the rollno %d" ,s.r);
printf("\n enter the marks");
scanf("%f",&s.m);
printf("\n the marks %f",s.m);
printf("\n enter the fee");
scanf("%lf",&s.f);
printf("\n the fee %lf",s.f);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
union student
{
char g;
int r;
float m;
double f;
}s;
clrscr();
printf("size of union %d",sizeof(s));
printf("\n enter the grade");
s.g=getche();
printf("\n the grade %c",s.g);
printf("\n enter the rollno");
scanf("%d",&s.r);
printf("\n the rollno %d" ,s.r);
printf("\n enter the marks");
scanf("%f",&s.m);
printf("\n the marks %f",s.m);
printf("\n enter the fee");
scanf("%lf",&s.f);
printf("\n the fee %lf",s.f);
getch();
}