/*Program to swap the values of 2 integers using bitwise XOR operator*/
#include
void main()
{
int value1, value2;
printf("Enter the values of two integers:\n");
scanf("%d %d",&value1,&value2);
printf("\n-----------Before Swapping-------------");
printf("\nBefore swapping the values of variables are:\n");
printf("Value1=%d \nValue2=%d",value1,value2);
value1= value1^value2;value2= value1^value2;value1= value1^value2;
printf("\n\n\n-----------After Swapping-------------");
printf("\nAfter swapping the values of variables are:\n");
printf("Value1=%d \nValue2=%d",value1,value2);
}
Bitwise XOR
0 comments: