#include<iostream.h>
#include<conio.h>
class num
{
int a;
public:
void swap(int&x,int&y)
{
a=y;
y=x;
x=a;
}
};
int main()
{
clrscr();
int a,b;
cout<<"Enter the number a and b :";
cin>>a>>b;
cout<<"\na="<<a<<"\nb="<<b;
num n;
n.swap(a,b);
cout<<"\na and b swaped \na="<<a<<"\nb="<<b;
getch();
return 0;
}
0 comments:
Post a Comment