Why this code is printing 1? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
28th Apr 2019, 9:11 AM
Yamin Mansuri
Yamin Mansuri - avatar
8 Answers
+ 7
2 = true, 4 = true, true && true = true (1).
28th Apr 2019, 9:15 AM
Anna
Anna - avatar
+ 10
Thanks Anna
28th Apr 2019, 9:24 AM
Yamin Mansuri
Yamin Mansuri - avatar
+ 8
It's logically true, that's why it's true.
29th Apr 2019, 12:19 PM
Nasirā¤
Nasirā¤ - avatar
+ 7
Werg Serium Yes bro I tried that
29th Apr 2019, 5:47 PM
Yamin Mansuri
Yamin Mansuri - avatar
+ 5
any int not 0 is true, so if you gat -2 && 4 that's still true, that's C for you
28th Apr 2019, 9:25 AM
āœ³AsterisKāœ³
āœ³AsterisKāœ³ - avatar
+ 5
Yamin Mansuri , Anna and *AsterisK* have answered your question right so no need to message me.
28th Apr 2019, 11:42 AM
Sonic
Sonic - avatar
+ 1
Hey Yamin don't use &&, use only & instead and you will get 0.
28th Apr 2019, 8:24 PM
Werg Serium
Werg Serium - avatar
0
Every number different of 0 is true. It's sucks but it's reallity ā˜¹
28th Apr 2019, 2:56 PM
Werg Serium
Werg Serium - avatar