Swap Two variable value using XOR – C Program
write a c program to swap(interchange) value of two variable using XOR.
#include<stdio.h>
#include<coino.h>
void main()
{
int a, b,
printf("Enter the First Vaue A = ");
scanf("%d",&a);
printf("\nEnter thr Second Value B = ");
scanf("%d",&b);
a ^= b;
b ^= a;
a ^= b;
printf("The value of A = %d",a);
printf("\nThe value of B =%d",b);
getch();
}
The c program swap using XOR output is :
Enter the First Vaue A = 25
Enter thr Second Value B = 102
The value of A = 102
The value of B = 25