//Program on Nested Structure
#include "stdio.h"
#include "conio.h"
struct adress {
char ct[10];
char dist[10],state[5];
long int pin;
};
struct emp {
char name[10];
int age,sal;
struct adress a;
};
void main()
{
struct emp e[2];
int i;
clrscr();
for(i=0;i<=1;i++)
{
printf("Enter [%d]st Employee's Name,Age,salary :: ", i);
scanf("%s%d%d",e[i].name,&e[i].age,&e[i].sal);
printf("\nEnter city, district,state & pincode ::");
scanf("%s%s%s%ld",e[i].a.ct,e[i].a.dist,e[i].a.state,&e[i].a.pin);
}
for(i=0;i<=1;i++)
{
printf("\n[%d]st Employee's Name :: %s",i,e[i].name);
printf("\n[%d]st Employee's Age :: %d ",i,e[i].age);
printf("\n[%d]st Employee's Salary :: %d",i,e[i].sal);
printf("\n[%d]st Employee's City :: %s ",i,e[i].a.ct);
printf("\n[%d]st Employee's District :: %s",i,e[i].a.dist);
printf("\n[%d]st Employee's State :: %s",i,e[i].a.state);
printf("\n[%d]st Employee's Pin :: %ld",i,e[i].a.pin);
}
getch();
}
#include "stdio.h"
#include "conio.h"
struct adress {
char ct[10];
char dist[10],state[5];
long int pin;
};
struct emp {
char name[10];
int age,sal;
struct adress a;
};
void main()
{
struct emp e[2];
int i;
clrscr();
for(i=0;i<=1;i++)
{
printf("Enter [%d]st Employee's Name,Age,salary :: ", i);
scanf("%s%d%d",e[i].name,&e[i].age,&e[i].sal);
printf("\nEnter city, district,state & pincode ::");
scanf("%s%s%s%ld",e[i].a.ct,e[i].a.dist,e[i].a.state,&e[i].a.pin);
}
for(i=0;i<=1;i++)
{
printf("\n[%d]st Employee's Name :: %s",i,e[i].name);
printf("\n[%d]st Employee's Age :: %d ",i,e[i].age);
printf("\n[%d]st Employee's Salary :: %d",i,e[i].sal);
printf("\n[%d]st Employee's City :: %s ",i,e[i].a.ct);
printf("\n[%d]st Employee's District :: %s",i,e[i].a.dist);
printf("\n[%d]st Employee's State :: %s",i,e[i].a.state);
printf("\n[%d]st Employee's Pin :: %ld",i,e[i].a.pin);
}
getch();
}
plz give output of program
ReplyDelete