You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to Swap the Conte...

18 lines
451 B
C

/*
* C program to swap the contents of two numbers using bitwise XOR
* operation. Don't use either the temporary variable or arithmetic
* operators
*/
#include <stdio.h>
void main()
{
long i, k;
printf("Enter two integers \n");
scanf("%ld %ld", &i, &k);
printf("\n Before swapping i= %ld and k = %ld", i, k);
i = i ^ k;
k = i ^ k;
i = i ^ k;
printf("\n After swapping i= %ld and k = %ld", i, k);
}