1. "Assume integer variable A holds 60 and variable B holds 13 then:

A&B will give 12"

Why is this?

2. Originally Posted by tmt
"Assume integer variable A holds 60 and variable B holds 13 then:

A&B will give 12"

Why is this?
Write the binary represetation of $A$ and $B$ and then add them.
For example, the binary representation of $A$ is $0011 1100$.

Originally Posted by evinda
Write the binary represetation of $A$ and $B$ and then add them.
For example, the binary representation of $A$ is $0011 1100$.
I get 01001001 how is this 12?

4. Originally Posted by tmt
I get 01001001 how is this 12?
You have to use this truth table for &:

$$\begin{bmatrix} p & q & p \& q \\ 0 & 0 & 0\\ 0 & 1 & 0 \\ 1 & 1 & 1\\ 1 & 0 &0 \end{bmatrix}$$

Then, the result will be $0000 1100$.

5. In C, Java and other languages, & is the bitwise and of the integer operands. So for example, 6 & 4 is 110 & 100 = 100 = 4. Similarly | is the bitwise or operator. So 6 | 4 = 110 | 100 = 110 = 6. Similarly ^ is the bitwise exclusive or operator. So 6 ^ 4 = 010 = 2.