I'm learning C basics and I'm trying to understand why the output of this example is 1 2 1 1
:
int main()
{
int a, b, c, d;
a = b = c = d = 1;
a = ++b > 1 || ++c > 1 && ++d > 1;
printf("%d%d%d%d", a, b, c, d);
}
- As far as I understand, only the left operand before Logical OR
||
is getting evaluated because it is True and there is no need to evaluate the right one. The right operand is not evaluated. Is this right? - The left operand is true because
++b > 1
equals1
(2 is larger than 1) anda = 1
. Right?