Reputation: 1031
I was debugging a C code and came across below expression. I want to know, how below expression will be evaluated in c?
x += y*2 != z;
Upvotes: 1
Views: 51
Reputation: 726489
To figure out expressions like that start with the precedence table:
!=
has precedence of 7, so it will be evaluated next+=
has precedence of 14, so it will be evaluated last.Therefore, x
will be incremented by 1
if y*2
is not equal to z
.
Upvotes: 2