#include<stdio.h>
#include<conio.h>
struct addr
{
char street[60];
char city[60];
char state[60];
long int pin_code;
};
struct customer
{
char name[60];
char account_no[20];
char profession[40];
struct addr address;
};
void main()
{
struct customer *list[100];
int i,n;
clrscr();
printf("Program to input the name,account no.,profession,address and display it
by using nested structures.");
printf("\n\t-------------------------OUTPUT------------------------");
printf("\n\nenter the no. of records");
scanf("%d",&n);
if(n==0)
{
printf("\nthe no. of records are =0");
getch();
exit(0);
}
printf("\nenter the required information");
fflush(stdin);
for(i=0;i<n;i++)
{
printf("\n\nenter the record of %d customer",i+1);
printf("\n\nenter the name:");
scanf("%s",&list[i]->name);
printf("\nenter the account no.:");
gets(list[i]->account_no);
printf("\nenter the profession:");
gets(list[i]->profession);
printf("\nenter the address:->");
printf("\nenter the street:");
gets(list[i]->address.street);
printf("\nenter the city:");
gets(list[i]->address.city);
printf("\nenter the state:");
gets(list[i]->address.state);
printf("\nenter the pin code:");
scanf("%ld",&(list[i]->address.pin_code));
fflush(stdin);
}
printf("\ndetails of various customers\n");
for(i=0;i<n;i++)
{
printf("\n\nthe record of the %d customer is",i+1);
printf("\n\nname-> %s",list[i]->name);
printf("\naccount no.-> %s",list[i]->account_no);
printf("\nprofession-> %s",list[i]->profession);
printf("\naddress is:");
printf("\n\nstreet-> %s",list[i]->address.street);
printf("\ncity-> %s",list[i]->address.city);
printf("\nstate-> %s",list[i]->address.state);
printf("\npin code-> %ld",list[i]->address.pin_code);
}
getch();
}