Binary XOR Operator copies the bit if it is set in one operand but not both.
Consider the following program:
#include<stdio.h>
int main()
{ int i,j,k;
i=11^5;
j=12^3;
k=15^4;
printf("\n%d\n%d\n%d",i,j,k);
}
output:
14
15
11
Explanation:
i=11^5
converting to binary
i=1011^0101=1110
1110 in decimal is 14
so i=14
converting to binary
i=1100^0011=1111
1111 in decimal is 15
so j=15
converting to binary
i=1111^0100=1011
1011 in decimal is 11
so i=11
0 comments:
Post a Comment