Sei sulla pagina 1di 3

//PROGRAM FOR IMPLEMNETING ARRAY OF STRUCTURE

#include "iostream.h"
#include "stdio.h"
struct add
{
int houseno ;
char city[10] ;
char state[10] ;
};
struct emp
{
int empno ;
char name[20] ;
char desig[10] ;
float pay ;
add address ;
}worker ;
emp e1[5];
void enter(void);
void display(int a);
void main()
{
int eno ,i ;
char ch ;
cout<<"\n Enter information for 5 employees";
enter() ;
do
{
cout<<eno;
int flag=0 ;
for(i=0;i<5;++i)
{
if(e1[i].empno==eno)
{ display(i) ;
flag=1 ;
break ;

}
}
if(!flag)
{
cout<<"\n"<<"Sorry ..Wrong registration number"<<"\n " ;
}
cout<<"\n"<<"Display more ?.."<<ch ;
}
while(ch=='y'|| ch=='Y');
}
void enter()
{
for(int i=0 ;i<5;i++)
{
cout<<e1[i].empno ;
cout<<"\nENTER EMPLOYEE NAME ::" ;
gets(e1[i].name) ;
cout<<"\nENTER EMPLOYEE desigation::" ;
gets(e1[i].desig) ;
cout<<e1[i].address.houseno ;
cout<<"\nENTER EMPLOYEE City ::" ;
gets(e1[i].address.city) ;
cout<<"\nENTER EMPLOYEE State ::" ;
gets(e1[i].address.state ) ;
cout<<e1[i].pay ;
cout<<"\n" ;
}}
void display(int a)
{
cout<<"EMPLOYEE DATA ........."<<"\n" ;
cout<<"\nEMPLOYEE NO.::" ;
cout<<e1[a].empno ;
cout<<"\nEMPLOYEE NAME ::" ;
puts(e1[a].name) ;
cout<<"\n EMPLOYEE desigation::" ;
puts(e1[a].desig) ;
cout<<"\nEMPLOYEE House no.::" ;
cout<<e1[a].address.houseno ;
cout<<"\ City ::" ;
puts(e1[a].address.city) ;

cout<<"\nState::" ;
puts(e1[a].address.state ) ;
cout<<"\nEMPLOYEE PAY ::" ;
cout<<e1[a].pay ;
cout<<"\n" ;
}

Potrebbero piacerti anche