396 Programming and Data Structures
1220 Write a program to define the structure containing the details of the employee. The
structure may contain first, middle, last name, place, city & pincode. Use typedef to
create data type. Display the records of two employees.
main()
{
int j;
t^padef struct
char first[20];
char middle[20];
char last [15];
char city[15];
int pincode;
} name;
name person[2];
clrscr();
fo r (f=0,j<2,-j++)
I
printf ("nR ecord 'N o .: % d ”,j+ l);
printf ( “nFirst Name
scan)f(“°/os",person[j].first);
printf ("M iddle N a m e:");
scanf ( “%s",person [j].middle);
printf ("L a st N a m e:”);
scanf ("%s",person[j].last);
printf ("C ity & Pincode");
scanf ("% s %d",person[jj.city,&person[j].pincode);
I
fo r (j=0;j<2;j++)
I
printf ("nnFirst Name : %s",person[j].first);
printf C‘nMiddle Name : %s",person[j].middle);
printf ( “nLast Name : % s",person[j].last);
printf (" n C ity & Pincode: %s - %d",person[j1.city,person[j].pincode);
)
O U TP UT :
Record N o .: 1
First Name : Jay
Middle Name : Mohan
Last Name : Deshmukh
City & Pincode : Nanded - 431 602