Monday, 20 July 2015

Swapping of two numbers using Bit wise Operators in C language



Program:

/* C Program for Swapping of two numbers using Bit wise Operators */
#include < stdio.h >
void main(  )
{
        int a, b;

        a = 10;
        b = 20;
        a = a ^ b;
        b = a ^ b;
        a = b ^ a;
        printf("\n a = %d\t b = %d", a, b);
}

Output:

a = 20    b = 10





0 comments:

Post a Comment