[Solved] What does “&” do in this example?


As the comments and answer suggest, this is a bitwise operator. Bitwise operators treat their operands as groups of bits when they operate on them. A bitwise and will, as I’m sure you could guess, and two bits, so a truth table would look like:

 A | B | A & B
---|---|------
 0 | 0 |   0
 0 | 1 |   0
 1 | 0 |   0
 1 | 1 |   1

So when you and your a and b, it will take the binary values of them both, 1010 and 1101 respectively, and and each a bit with its corresponding b bit, so

 1010  -a, or 10
&1101  -b, or 13
-----
 1000  -c, or 8

11

solved What does “&” do in this example?