Passing structure to the Function using call by value and call by reference.....
#include<iostream.h> #include<conio.h> #include<stdio.h> struct person{ char name[50]; int age; }; void disp_val(person p1) { cout<<"\nName of the Person is :- "<<p1.name; cout<<"\nAge of the Person is :- "<<p1.age; } void disp_ref(person *p1) { cout<<"\nName of the Person is :- "<<p1->name; cout<<"\nAge of the Person is :- "<<p1->age; } void main() { clrscr(); person p; cout<<"Enter the Person name:- "; gets(p.name); cout<<"Enter Age of person:- "; cin>>p.age; cout<<"\n====================================================\n"; cout<<"\nDisplay Using Structure Passing by value"; disp_val(p); cout<<"\n====================================================\n"; cout<<"\nDisplay Using Structure Passing by reference"; disp_ref(&p); getch(); }
No comments:
Post a Comment