Professional Documents
Culture Documents
LAB-4
LAB-4
LAB-4
ALGORITHM:
1)START
2)Create a class Employee with empno,name,deptname and
designation as data members as private(Default).
3)Create a string edptname to read the department name.
4)Create a friend function ListDeptWise() for listing the details of
employees for a given dept
5)Declare Object of class in main function and Print the output using
member function display()
6)STOP
PROGRAM:
#include <iostream>
#include <string>
using namespace std;
class employee {
int EmpNo;
string Name;
string DeptName;
string Designation;
public:
void emp(int eno, string enm, string edpt, string edesig) {
EmpNo = eno;
Name = enm;
DeptName = edpt;
Designation = edesig;
}
void Display() {
employee obj[10];
obj[1].emp(1, "Aruna", "Network", "Boss");
obj[2].emp(2, "Charan", "Designing", "Clerk");
obj[3].emp(3, "Vishnu", "Accounts", "CEO");
obj[4].emp(4, "Bindu", "Network", "Boss");
obj[5].emp(5, "Rohit", "Accounts", "CAO");
obj[6].emp(6, "Prathima", "Network", "Informer");
obj[7].emp(7, "Nithin", "Network", "Clerk");
obj[8].emp(8, "Ruchitha", "Network", "Boss");
obj[9].emp(9, "Meera", "Designing", "Informer");
obj[0].emp(10, "Sowmya", "Accounts", "CEO");
ListDeptWise(obj);
return 0;
}
OUTPUT:
Department is :Network
employee number :4
Name is :Bindu
Department is :Network
Designation is :Boss
employee number :6
Name is :Prathima
Department is :Network
Designation is :Informer
employee number :7
Name is :Nithin
Department is :Network
Designation is :Clerk
employee number :8
Name is :Ruchitha
Department is :Network
Designation is :Boss
RESULT: