Program to Illustrate use of UNION

#include<stdio.h>
#include<conio.h>
union stu
{
int roll;
char name[50];
}k;
void main()
{
clrscr();
printf("\nEnter Roll no. ");
scanf("%d",&k.roll);
printf("\nRoll= %d",k.roll);
printf("\n\nEnter Name ");
scanf("%s",&k.name);
printf("\nName = %s",k.name);
getch();
}

Leave a Reply