This program swaps two numbers without using the third variable. It can be done by using the Bitwise operator
#include <stdio.h> int main(){ int a=10; int b=20; printf("First value is %d Second value is %d",a,b ); a = a ^ b; b = a ^ b; a = a ^ b; printf("== After Swapping =="); printf("First value is %d Second value is %d",a,b ); return 0; }
First value is 10 Second value is 20 == After Swapping == First value is 20 Second value is 10
Comments :