Operator precedence in C for the statement z=++x||++y&&++z

后端 未结 4 1541
感情败类
感情败类 2021-01-16 09:48

I was studying operator precedence and I am not able to understand how the value of x became 2 and that of y and z is

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-16 10:42

    z=++x||++y&&++z;

    NOTE: ++ has higher priority than ||

    Now after this line is executed the value of x is incremented and x=2 now ++y&&++z are never executed as the first condition is true and hence you are getting the value as x=2 y=1 z=1

提交回复
热议问题