Code Competitions

Coding competition

Tuesday, 14 May 2013

program to show the use of union

#include<stdio.h>
#include<conio.h>
union employee
{
    int a;
    char b[4];
};
void main()
{
    union employee e1;
    clrscr();
    printf("Enter values\n");
    scanf("%d",&e1.a);
    printf("a= %d",e1.a);
    scanf("%s",e1.b);
    printf("\nb= %s",e1.b);
       //    e1.a=5;
    printf("\na= %d",e1.a);
    getch();
}

No comments:

Post a Comment