You are on page 1of 1

//===========================================================================

//Exercise 12: WAP to take name, address as character array, age as int, salary
//as float and contains inline functions to set the values and display it.
//===========================================================================
#include <iostream.h>
#include <conio.h>
#include <math.h>
//------------------------------------
// Class Definition
//------------------------------------
class EMP{
char name[20];
char add[20];
int age;
float sal;
public:
void getData(){
cout<<"\nEnter Employee's Name : ";
cin>>name;
cout<<"Enter Employee's Address: ";
cin>>add;
cout<<"Enter Employee's Age : ";
cin>>age;
cout<<"Enter Employee's Salary : ";
cin>>sal;
}
void putData(){
cout<<"\nName : "<<name;
cout<<"\nAddress : "<<add;
cout<<"\nAge : "<<age;
cout<<"\nSalary : "<<sal;
}
void printData(){
cout<<"\t"<<name<<"\t"<<add<<"\t"<<age<<"\t"<<sal;
}
};
//------------------------------------
// Main Function
//------------------------------------
void main(){
clrscr();
EMP b[5];
for(int i=0;i<5;i++){
cout<<"\n=======================================================";
cout<<"\n=============ENTER THE DETAILS OF EMPLOYEE : "<<i+1;
cout<<"\n=======================================================";
b[i].getData();
}
cout<<"\n=======================================================";
cout<<"\n============= DETAILS OF EMPLOYEE =====================";
cout<<"\n=======================================================";
cout<<"\n"<<"S.No."<<"\t"<<"Name"<<"\t"<<"Address"<<"\t";
cout<<"Age"<<"\t"<<"Salary";
for(i=0;i<5;i++){
cout<<"\n"<<i+1;
b[i].printData();
}
getch();
}

You might also like