Tag Archive for C++ Program

Swap two numbers using bitwise operators

#include <iostream>
#include <conio.h>

int main(){
int i = 10;
int k = 20;

printf("\n value of i=%d k=%d before swapping", i, k);

i = i ^ k;
k = i ^ k;
i = i ^ k;

printf("\n value of i=%d k=%d after swapping", i, k);
getch();
return 0;
}
www.000webhost.com