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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -