Prog 27 : write a program for input name, age and salary for 3 employees and print it.
#include<iostream.h>
#include<conio.h>
class emp
{
public:
int age;
char name[25];
float salary;
void getdata()
{
cout<<"\n Enter name";
cin>>name;
cout<<"\n Enter age";
cin>>age;
cout<<"\n Enter salary";
cin>>salary;
}
void putdata()
{
cout<<"\n Name ="<<name; cout<<"\n Age ="<<age; cout<<"\n Salary ="<<salary;
}
};
void main()
{
clrscr();
emp e[3];
for(int i=0;i<3;i++)
{
e[i].getdata();
}
for(int i=0;i<3;i++)
{
e[i].putdata();
}
getch();
}
Output:
Enter name kd
Enter age 20
Enter salary 90000
Enter name kd1
Enter age 21
Enter salary 80000
Enter name kd2
Enter age 22
Enter salary 100000
Name =kd
Age =20
Salary =90000
Name =kd1
Age =21
Salary =80000
Name =kd2
Age =22
Salary =100000
#include<iostream.h>
#include<conio.h>
class emp
{
public:
int age;
char name[25];
float salary;
void getdata()
{
cout<<"\n Enter name";
cin>>name;
cout<<"\n Enter age";
cin>>age;
cout<<"\n Enter salary";
cin>>salary;
}
void putdata()
{
cout<<"\n Name ="<<name; cout<<"\n Age ="<<age; cout<<"\n Salary ="<<salary;
}
};
void main()
{
clrscr();
emp e[3];
for(int i=0;i<3;i++)
{
e[i].getdata();
}
for(int i=0;i<3;i++)
{
e[i].putdata();
}
getch();
}
Output:
Enter name kd
Enter age 20
Enter salary 90000
Enter name kd1
Enter age 21
Enter salary 80000
Enter name kd2
Enter age 22
Enter salary 100000
Name =kd
Age =20
Salary =90000
Name =kd1
Age =21
Salary =80000
Name =kd2
Age =22
Salary =100000
No comments:
Post a Comment