PROGRAM TO PERFORM CALL BY REFERENCE
Pr ogram to perform call by reference: Code: #include<iostream.h> #include<conio.h> void exchange(int &a,int &b) { int c; c=a; a=b; b=c; } void main() { clrscr(); int a,b; cin>>a>>b; cout<<"\t"<<"\nbefore function call\t"; cout<<a<<"\t"<<b; exchange(a,b); cout<<"\t"<<"\nafter function call\t"; cout<<a<<"\t"<<b; getch(); } Output: 3 5 before function call 3 5 after function call 5 3
Comments
Post a Comment