Q. Write a C++ program to swap two numbers without using third variable.
Answer:
Following program shows that swapping of two numbers without using third variable.
Output:

Answer:
Following program shows that swapping of two numbers without using third variable.
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout<<"\n Enter Two Numbers : \n";
cin>>a>>b;
cout<<"\n Before Swapping : \n";
cout<<a<<"\n"<<b<<"\n";
a=a+b;
b=a-b;
a=a-b;
cout<<"\n After Swapping : \n";
cout<<a<<"\n"<<b;
return 0;
}
Output:



