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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -