Thursday, 21 July 2011

Program to swap two values by using: call by Address in c++

Do you like this post?
#include
#include
void swap_by_add(int &x,int &y);
void main()
{
int a,b;
clrscr();
cout<<"Enter the value of a & b: "; cin>>a>>b;
cout<<"\n\t\t\tBefore calling"< swap_by_ref(a,b);
cout<<"\n\t\t\tAfter calling"< getch();
}
void swap_by_add(int &x,int &y)
{
int temp;
temp=x;
x=y;
y=temp;
}

No comments:

Post a Comment