+ 1
What is logic behind Answer for this code
5 Antworten
+ 2
Yes.
&& , || are logical operators, works as compound conditional expressions..
&, | are bitwise logical operators works at bit level manipulations.
+ 2
Jayakrishna🇮🇳 ooh I got confused by &&
So if
a = 0
b = 1
Printf(" %d, %d", a||b , a&&b );
O/p = 1, 0
a = 4
b = 6
Printf(" %d, %d", a|b , a&b );
O/p = 6, 4
Is this correct ?
+ 1
Anything , other than 0 value will be true in boolean equivalence. 0 means false.
So 2&&4 is true && true => true
true => 1 as integer value is the answer.
+ 1
Jayakrishna🇮🇳 ok but what if I want to print answer by this logic -
In binary 2 = 10 and 4= 100 and their AND operation will result zero
How can I achieve this?
+ 1
Use bitwise and operator & => a&b
printf("%d",a&b)
a&b => 0010 & 0100 = 0000
a&&b => 2&&4 => true && true = true