Answer to Question #190263 in C++ for Ahmed Nawaz

Question #190263

Create an 'Employee' class with emp_id, emp_name and emp_gender as data members - member function to input the details of employee - member function to output the details of employee. Write a main function to create objects of Employee class. Take the input of 3 different employee from the user and display the details on the console output screen.


1
Expert's answer
2021-05-07T09:04:52-0400
#include<iostream>
#include<string>
using namespace std;
class Employee
{
public:
    char emp_name[30],emp_gender[7],emp_id[10];
    void Input()
    {
        cout<<"\nEnter employee id : ";
        cin.getline(emp_id,10);
        cout<<"\nEnter name of employee : ";
        cin.getline(emp_name,30);
        cout<<"\nEnter gender of employee : ";
        cin.getline(emp_gender,7);
    }
    void Output()
    {
        cout<<"\nEmployee ID : "<<emp_id;
        cout<<"\nEmployee Name : "<<emp_name;
        cout<<"\nGender : "<<emp_gender;
    }
};
int main()
{
    Employee e[3];
    int i;
    for(i=0;i<3;i++)
    {
        e[i].Input();
    }
    for(i=0;i<3;i++)
    {
        e[i].Output();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS