PROGRAM
Program for passing structures to functions through call by value and call by reference.#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct Emp{ int empno;
char name[25];
double salary;
};
void ReadEmp(Emp & e)
{ clrscr();
cout<<"\n Enter employee no :";
cin>>e.empno;
cout<<"\n Enter employee name :";
gets(e.name);
cout<<"\n Enter employee salary";
cin>>e.salary;
}
void ShowEmp(Emp e)
{ cout<<"Employee Details \n";
cout<<"Empno:"<<e.empno<<endl;
cout<<"Name:"<<e.name<<endl;
cout<<"Salary:"<<e.salary<<endl;
}
void main()
{ Emp e1;
ReadEmp(e1);
ShowEmp(e1);
getch();
}
========================================================================
OUTPUT:
Enter employee no: 01
Enter employee name: Bhavesh
Enter employee salary:2500000
Employee Details
Empno:1
Name:Bhavesh
Salary:2500000
========================================================================
No comments:
Post a Comment