#include<iostream.h>
#include<conio.h>
void cbr(int &a,int &b)   //Formal argument as reference variable
{
                int c;
                c=a;
                a=b;
                b=c;
                cout<<"\tFunction Call"<<endl;
                cout<<"A = "<<a<<"\tB = "<<b<<endl;
                cout<<"Address of A = "<<(unsigned)&a<<endl;
                cout<<"Address of B = "<<(unsigned)&b<<endl;
}
void main()
{
                int x,y;
                clrscr();
                cout<<"Enter Two Value : \n";
                cin>>x>>y;
                cout<<"\n\tBefore Function Call \n";
                cout<<"X = "<<x<<"\tY = "<<y<<endl;
                cout<<"Address of X = "<<(unsigned)&x<<endl;
                cout<<"Address of Y = "<<(unsigned)&y<<endl;
                cbr(x,y);               //Function call by call by value technique
                cout<<"\tAfter Function Call is main() \n";
                cout<<"X = "<<x<<"\tY = "<<y<<endl;
                cout<<"Address of X = "<<(unsigned)&x<<endl;
                cout<<"Address of Y = "<<(unsigned)&y<<endl;
                getch();
}

72.PNG

Advertisements