17 Nov 2019

  • November 17, 2019
  • Amitraj
C++ program to swap two numbers without using  temporary and Arithmetic Operator

#include<iostream>
using namespace std;
int  main()
{
 int a,b;
 cout<<"Enter 2 no.:";
 cin>>a>>b;

 a=a^b;
 b=a^b;
 a=a^b;
 cout<<"Result is:"<<a<<" "<<b;
 return 0;
}

OUTPUT:

Enter 2 no.: 10   20
Result is:     20   10

Translate

Popular Posts