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
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
0 comments:
Post a Comment