Sunday, June 24, 2012

Swap number using two variable using bit-wise operators



#include<stdio.h>
#include<conio.h>
int main(void)
{
   int x,y,z;
   printf("\nEnter First Number : ");
   scanf("%d",&x);
   printf("\nEnter Second Number : ");
   scanf("%d",&y);
   x^=y;
   y^=x;
   x^=y;
   printf("\n\nAfter Swapping\n\n");     printf("\nFirst Number :
          %d\nSecond Number : %d",x,y);

   return 0;
}

0 comments:

Post a Comment