#include<stdio.h>
#include<conio.h>
struct dep
{
char depname[12];
char post[12];
float bpay;
};
struct add
{
int hnum;
char place[9];
char city[8];
char state[8];
};
struct employee
{
int em_no;
char name[10];
struct dep depart;
struct add address;
};
void main()
{
struct employee data;
printf("Enter employee's data :\n");
printf("Employee no. : %d");
scanf("%d",&data.em_no);
printf("Employee name : ");
scanf("%s",&data.name);
printf("Department:");
scanf("%s",&data.depart.depname);
printf("Post : ");
scanf("%s",&data.depart.post);
printf("Basic Pay : ");
scanf("%f",&data.depart.bpay);
printf("House Number : ");
scanf("%d",&data.address.hnum);
printf("Place : ");
scanf("%s",&data.address.place);
printf("City : ");
scanf("%s",&data.address.city);
printf("State : ");
scanf("%s",&data.address.state);
printf("\nThe entered data is :\n");
printf("\nEmployee no. : %d",data.em_no);
printf("\nEmployee name : %s",data.name);
printf("\nDepartment: %s",data.depart.depname);
printf("\nPost : %s",data.depart.post);
printf("\nBasic Pay : %f",data.depart.bpay);
printf("\nHouse Number : %d",data.address.hnum);
printf("\nPlace : %s",data.address.place);
printf("\nCity : %s",data.address.city);
printf("\nState : %s",data.address.state);
getch();
}
|
|
| A program to enter and display the employee data using nested structure |
|
| |
|
|
|
|