swap two numbers without use of third variable and also arithmetic operations

+1 vote
asked Mar 23 by (130 points)

2 Answers

0 votes
answered 5 days ago by (260 points)

Use the XOR swap.

void swap( int* x, int* y )  {  
  if (y != x) { // important
    *x ^= *y;
    *y ^= *x;
    *x ^= *y;
0 votes
answered 4 days ago by (220 points)
//for swap two number in c


 void main()


   int a,b;

printf("enter two number which are storing at a and b");





printf(" a and b is %d, %d",a,b);

commented 3 days ago by (260 points)
its been already stated that to do not using third variable and arithmatic operations aswell
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.