Write a program of pass by reference


 

/* Write a program of pass by reference*/

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

clrscr();

int a,b;

void sW.A.P.(int &,int &);

cout<<“enter two numbers=”;

cin>>a>>b;

cout<<“\n before calling a=”<<a<<“b=”<<b;

sW.A.P.(a,b);

cout<<“\n after calling a=”<<a<<“b=”<<b;

getch();

}

void sW.A.P.(int &x,int &y)

{

int z;

z=x;

x=y;

y=z;

cout<<“\n after modification x=”<<x<<“y=”<<y;

}

output:

enter two numbers=10 20

before calling a=10 b=20

after modification x=20 y=10

after calling a=20 b=10

Comments are closed.