int a = 1, b = 2;
int c = a*b + b==0; // c = 0
cout << a*b + b==0; // outputs 4
c
evaluates to 0
because the operator precedence of the *
and +
operators is higher than ==
as a result of which c
essentially evaluates to (a*b+b)==0
which is false.
Why does putting the same expression in a cout
statement output 4?