I like to learn new technologies. These posts are for my own reference (I have habit of forgetting). If anybody finds these posts useful, then it will surely make me HaPpY.
Monday, January 21, 2013
Write a program to swap 2 numbers using bitwise operators
//Write a program to swap 2 number without arithmetic operator
#include <stdio.h>
int main() { int i=65; int k=120;
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); return 0; } OUTPUT:
No comments:
Post a Comment