Thursday, September 20, 2012

How to swap two numbers using bitwise operators? Program:

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

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete