13th Oct 2022, 8:01 AM
Laukesh singh
Laukesh singh - avatar
5 Answers
+ 2
Yes. && , || are logical operators, works as compound conditional expressions.. &, | are bitwise logical operators works at bit level manipulations.
13th Oct 2022, 9:12 AM
Jayakrishna 🇼🇳
+ 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 ?
13th Oct 2022, 9:06 AM
Laukesh singh
Laukesh singh - avatar
+ 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.
13th Oct 2022, 8:22 AM
Jayakrishna 🇼🇳
+ 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?
13th Oct 2022, 8:54 AM
Laukesh singh
Laukesh singh - avatar
+ 1
Use bitwise and operator & => a&b printf("%d",a&b) a&b => 0010 & 0100 = 0000 a&&b => 2&&4 => true && true = true
13th Oct 2022, 9:01 AM
Jayakrishna 🇼🇳