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;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

www.000webhost.com