#include <iostream.h>
#include <conio.h>
struct employee
{
char name[10] ;
char address[15] ;
long int telephone_numbers[5] ;
} ;
void main ( )
{
struct employee input ( ) ;
struct employee e ;
int i ;
clrscr ( ) ;
e = input ( ) ;
cout<<"\n\nEmployee Personal Information displayed... \n";
cout<<"\nName : "<<e.name ;
cout<<"\nAddress : "<<e.address ;
cout<<"\nTelephone Numbers : ";
for ( i = 0; e.telephone_numbers[i] > 0 && i < 5; i++ )
cout<<"\n"<<e.telephone_numbers[i] ;
getch ( ) ;
}
struct employee input ( )
{
struct employee temp ;
long int no;
int i ;
cout<<"Input the following -\n";
cout<<"Name : ";
cin>>temp.name ;
cout<<"Address : ";
cin>>temp.address;
cout<<"Telephone Numbers :\n";
cout<<"(terminate with -ve number,\n" ;
cout<<"if want to enter less than 5 telephone numbers)\n";
i = 0;
cin>>no ;
/* User can enter either 5 differrent telephone numbers or less.
If he enters less than 5 telephone numbers then he may terminate by entering negative
number */
while ( no > 0 && i < 4 )
{
temp.telephone_numbers[i] = no ;
i++ ;
//scanf("%ld",&no) ;
cin>>no;
}
temp.telephone_numbers[i] = no ;
return ( temp ) ;
}
0 comments:
Post a Comment