Operator precedence in C for the statement z=++x||++y&&++z -
i studying operator precedence , not able understand how value of x became 2 , of y , z 1
x=y=z=1; z=++x||++y&&++z; this evaluates to
x=2 y=1 z=1
++ has higher priority ||, whole rhs of assignment boils down increment of x , evaluation truth value (1).
z = ++x || ++y&&++z; truthy (1) never executed this because ++x evaluates true , second branch not executed. ++x 2 which, in boolean context, evaluates true or 1. z takes value of 1, giving observed final state.
Comments
Post a Comment