Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Swapping two numbers without using thrid variable with pointers in C in C

#include <stdio.h>
 
void swap(int *x, int *y){
    
  *x = *x ^ *y;
  *y = *x ^ *y;
  *x = *x ^ *y;
}
int main()
{
  int x, y;
 
  scanf("%d%d", &x, &y);
 
  printf("Before Swap x = %d y = %d\n", x, y);
 
  swap( &x,&y);
 
  printf("After Swap x = %d y = %d\n", x, y);
 
  return 0;
}