#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int a,b;
cout<<"Enter value for A:\t";
cin>>a;
cout<<"\nEnter value for B :\t";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"\nSwapped value for A is:\t"<<a;
cout<<"\nSwapped value for B is:\t"<<b;
getch();
return 0;
}
Out put of the above mentioned program will be:
Enter value for A: 3
Enter value for B: 5
Swapped value for A is: 5
Swapped value for B is: 3
#include<conio.h>
int main()
{
clrscr();
int a,b;
cout<<"Enter value for A:\t";
cin>>a;
cout<<"\nEnter value for B :\t";
cin>>b;
a=a+b;
b=a-b;
a=a-b;
cout<<"\nSwapped value for A is:\t"<<a;
cout<<"\nSwapped value for B is:\t"<<b;
getch();
return 0;
}
Out put of the above mentioned program will be:
Enter value for A: 3
Enter value for B: 5
Swapped value for A is: 5
Swapped value for B is: 3
0 Comments