Learn C ProgrammingLearn ProgrammingPrograms On StructuresResources

097. Define a structure Employee having elements emp_id, name, DOB, DOJ etc. Accept data and reprint it. (use structure within structure)

By September 18, 2012 September 5th, 2018 No Comments
#include<stdio.h>
#include<conio.h>  

struct Date
{
	int mm,dd,yy;
};

struct Employee
{
char name[50];
 int emp_id;
 struct Date DOB,DOJ;
};

main()
{   int i;
	struct Employee e;
	clrscr();
		printf("\nEnter name           : ");
		scanf("%s",&e.name);
		printf("\nEnter emp_id.        : ");
		scanf("%d",&e.emp_id);
		printf("\nEnter Date of Joining\n ");
		printf("(dd-mm-yy) : ");
		scanf("%d-%d-%d", &e.DOJ.dd,&e.DOJ.mm,&e.DOJ.yy);
		printf("\nEnter Date of birth\n ");
		printf("(dd-mm-yy) : ");
		scanf("%d-%d-%d", &e.DOB.dd,&e.DOB.mm,&e.DOB.yy);

		printf("\nName           : %s",e.name);
		printf("\nEmployee ID    : %d",e.emp_id);
		printf("\nEnter DOJ      : %d-%d-%d", e.DOJ.dd,e.DOJ.mm,e.DOJ.yy);
		printf("\nEnter DOB      : %d-%d-%d", e.DOB.dd,e.DOB.mm,e.DOB.yy);

	getch();
}


Leave a Reply

DEMO01