why this result shows 0? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why this result shows 0?

https://code.sololearn.com/c2H3Vj9Cxzk8/?ref=app I thought a&&a is true, so result will be 1. but it wasn't. Why it shows 0, instead of 1? #include <iostream> using namespace std; int main() { int a=0; cout << (a&&a); return 0; }

28th Jan 2020, 3:23 AM
sollex
sollex - avatar
1 Answer
+ 5
a=0 which is false so the next 'a' is not even looked at by the compiler and the whole expression is evaluated to false which is a binary 0.
28th Jan 2020, 3:37 AM
Avinesh
Avinesh - avatar