Code:
#include <iostream.h>
#include <conio.h>
struct Address
{
char house[10], area[30], city[20];
};
struct employee
{
int id;
char name[50], designation[50];
Address address;
float basic;
}e;
int main()
{
clrscr();
cout<<"Enter employee ID: ";
cin>>e.id;
cin.ignore(1,'\0');
cout<<"\nEnter name: ";
cin.getline(e.name, 50);
cout<<"\nEnter designation: ";
cin.getline(e.designation,50);
cout<<"\nEnter address: ";
cout<<"\n\tHouse: ";
cin.getline(e.address.house,10);
cout<<"\n\t Area: ";
cin.getline(e.address.area,30);
cout<<"\n\t City: ";
cin.getline(e.address.city,20);
cout<<"\nDisplaying..";
cout<<"\nEmployee ID: "<<e.id;
cout<<"\nName: "<<e.name;
cout<<"\nDesignation: "<<e.designation;
cout<<"\nAddress: "<<e.address.house<<", "<<e.address.area<<", "<<e.address.city;
getch();
return 0;
}
Output:
Enter Employee ID: <some number>
Enter name: <some name>
Enter designation: <some designation>
Enter address:
House: <some house no.>
Area: <area>
City: <city>
Displaying..
Employee ID: <ID>
Name: <name>
Designation: <designation>
Address: <house>, <area>, <city>