# include <stdio.h>

void swap(int *a, int *b)
        {
        *a ^= *b ^= *a ^= *b;
        }

int main()
        {
        int a=45, b= 56;
//      a ^= b ^= a ^= b;
        swap(&a,&b);
        printf("%d %d",a,b);
        }

This code gives output 0, 45
While if we uncomment the line in main function and don't use swap
function, we get correct value. Explain why the same line when used in
swap function gives such output.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to