READ INFORMATION OF A PERSON USING STRUCTURE AND UNION

/*PROGRAM TO READ INFORMATION OF A PERSON FROM KEYBOARD AND PRINT THE SAME ON SCREEN USING STRUCTURE AND UNION*/
#include<stdio.h>
#include<conio.h>
void main()
{
union doj
{
char date[10];
};
struct person
{
char name[15];
int salary;
union doj d1;
}p1;
clrscr();
printf(“Enter name of the person: “);
gets(p1.name);
printf(“Enter date of joining: “);
gets(p1.d1.date);
printf(“Enter salary of the person: “);
scanf(“%d”,&p1.salary);
printf(“\nThe given information of the person is:\n”);
printf(“Name of person is: %s\n”,p1.name);
printf(“Date of joining is: %s\n”,p1.d1.date);
printf(“Salary of the person is: %d”,p1.salary);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *