C++ language

adplus-dvertising
Program Of Swapping in C++
Previous Home Next

Example:

#include<stdio.h>
#include<conio.h>
void main()
{
int a, b ;
cout<<"\n Enter two values";
cin>>a>>b;
cout<<"value of a =" <<a<< "and b ="<<b;  
a=a+b;
b=a-b;
a=a-b;
cout<<"\n value after swaping";
cout<"\n value of a="<<<a;
cout<<"\nvalue of b="<<b;
}

Output:

Enter two values
12
23
value of a =10 and b =23
value after swappingvalue of a=23
value of b=12
Previous Home Next