HOME

Friday, April 10, 2015

SAMPLE C PROGRAM USING UNION

#include<stdio.h>
#include<conio.h>
union employ
{
    char name[20];
    int age;
    float salary;
};
void main()
{
    union employ e;
    printf("enter the employ name\n");
    gets(e.name);
    printf("%s",e.name);
    printf("\nenter the age\n");
    scanf("%d",&e.age);
    printf("%d",e.age);
    printf("\nenter the salary\n");
    scanf("%f",&e.salary);
    printf("%f",e.salary);
    printf("\nthe size is %d",sizeof(e));
}

No comments:

Post a Comment