Saturday, 18 February 2017

C++ program of entering employee data through functions and structure

In this program we will learn how to enter employee data through functions using structure.
The code is given below.

//code starts
#include <iostream>
#include <conio.h>

using namespace std;

struct emp
{
int id,salary;
char name[20];
};

void input (emp &emp1);

void show (emp emp1);

int main()
{
emp emp1;

input (emp1);

show (emp1);

     getch();

}

void input (emp &emp1)
{
cout<<"Enter Employee ID : "<<endl;
cin>>emp1.id;

cout<<"Employee Name : "<<endl;
cin>>emp1.name;

cout<<"Enter Salary :"<<endl;
cin>>emp1.salary;
}

void show (emp emp1)
{

cout<<"ID: "<<emp1.id<<endl;

cout<<"Name: "<<emp1.name<<endl;

cout<<"Salary: "<<emp1.salary;
}
//code ends


Share:

0 comments:

Post a Comment