Program in C++ to swap two numbers using Bitwise operator
#include<iostream> #include<conio.h> using namespace std; int main() { int a,b; cout<<"Enter two numbers:-"; cin>>a>>b; cout<<"Before swapping value of a="<<a<<" and value of b="<<b; a=a^b; b=b^a; a=a^b; cout<<"\nAfter swapping value of a="<<a<<" and value of b="<<b; getch(); }
Output :-
0 Comments