PROGRAM TO ENTER NAME AGE SALARY OF 5 EMPLOYEES USING ARRAY OF OBJECTS
/*WRITE A PROGRAM TO ENTER NAME AGE SALARY OF 5 EMPLOYEES USING ARRAY OF OBJECTS*/
#include<iostream.h>
#include<conio.h>
class employee
{
char name[20];
int age, salary;
public:
void getdata();
void putdata();
};
const int size=5;
void employee::getdata()
{
cout<<"\nenter name=";
cin>>name;
cout<<"\nenter age=";
cin>>age;
cout<<"\nsalary=";
cin>>salary;
}
void employee::putdata()
{
cout<<"\ndata";
cout<<"\nname is="<<name;
cout<<"\nage is="<<age;
cout<<"\nsalary is="<<salary;
}
void main()
{
employee emp[5];
for(inti=0;i<size;i++)
emp[i].getdata();
for(intj=0;j<size;j++)
emp[j].putdata();
getch();
}
----------------------------------------------------------
OUTPUT:-
#include<iostream.h>
#include<conio.h>
class employee
{
char name[20];
int age, salary;
public:
void getdata();
void putdata();
};
const int size=5;
void employee::getdata()
{
cout<<"\nenter name=";
cin>>name;
cout<<"\nenter age=";
cin>>age;
cout<<"\nsalary=";
cin>>salary;
}
void employee::putdata()
{
cout<<"\ndata";
cout<<"\nname is="<<name;
cout<<"\nage is="<<age;
cout<<"\nsalary is="<<salary;
}
void main()
{
employee emp[5];
for(inti=0;i<size;i++)
emp[i].getdata();
for(intj=0;j<size;j++)
emp[j].putdata();
getch();
}
----------------------------------------------------------
OUTPUT:-
0 comments