It comes under the category of bitwise operator. It is used base don some/multiple condition it gives true when both condition are true.
The output of the AND operator is 1 if both the corresponding bits of operand is 1. If either of bit is 0 or both bits are 0, the output will be 0. It is a binary operator(works on two operands) and is denoted by & symbol.
Logical AND
12 = 00001100 (In Binary)
25 = 00011001 (In Binary)
Bit Operation of 12 and 25
00001100
& 00011001
________
00001000 = 8 (In decimal)
As, bitwise operator works on every bits of data. The corresponding bits of two inputs are check and if both bits are 1 then only the output will be 1.
#include <stdio.h>
int main()
{
int a=12,b=39;
printf("Output=%d",a&b);
return 0;
}
This will return 4 because and operator will separate it in bits and then calculation is performed for AND operator in it.
0 Comment(s)