Aug 07
Operators Associativity
( ) left to right
~ ! ++ — (type) size of right to left
* /  % left to right
+ - left to right
<<   >> left to right
< <= > >= left to right
= =  != left to right
& (bitwise AND) left to right
^ (bitwise  XOR) left to right
| (bitwise OR) left to right
&& (logical AND) left to right
| | (logical OR) left to right
?: (conditional) right to left
=  *=  /=  %= -= >>= <<= &= ^= right to left
, (comma) left to right
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Twitter

written by Shweta

Aug 07

It is Exclusive OR operator. The XOR returns 1 only if one of two bits is 1.

Truth table

^ 0 1
0 0 1
1 1 0

Example

first operand 1 0 1 0 1 0 1 0
Second operand 1 1 0 0 0 0 1 1
result 0 1 1 0 1 0 0 1
  • A number Xored with another number twice gives the original number.

Example

main()

{

int a=10;

a = a^8;

printf (”\n%d”,a);

a=a^8;

printf (”\n%d”,a);

}

Output

2

10

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Twitter

written by Shweta

Aug 07

This operator operates on two operands. While operating upon these two operands they are compared on a bit by bit basis. Hence both the operands must be of same type.

Truth table

| 0 1
0 0 1
1 1 1

Example

first operand 1 0 1 0 1 0 1 0
Second operand 1 1 0 0 0 0 1 1
result 1 1 1 0 1 0 1 1
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Twitter

written by Shweta