Code Scrappers


Swap Two Numbers Using XOR - C program


              #include<stdio.h>
              #include<stdlib.h>

              void main()
              {
                 int a, b;

                 printf("\n enter two numbers : ");

                 scanf("%d%d", &a, &b);

                 a = a ^ b;
                 b = a ^ b;
                 a = a ^ b;

                 printf("\n After Swaping : ");

                 printf("\n a = %d and b = %d", a, b);
              }

          



Output

    enter two numbers : 5
    10

    After Swaping :
    a = 10 and b = 5