#include<iostream.h>
#include<conio.h>
class swap
{
private:
int a,b;
public:
void getdata(int x,int y)
{
a=x;
b=y;
}
void display();
};
void swap :: display()
{
int c;
c=a;
a=b;
b=c;
cout<<"\n First Number="<<a;
cout<<"\n Second Number="<<b;
}
main()
{
clrscr();
swap s1;
int p,q;
cout<<"Enter First Number=";
cin>>p;
cout<<"Enter Second Number=";
cin>>q;
s1.getdata(p,q);
s1.display();
getch();
}
No comments:
Post a Comment