C Programming: Understanding Logical Operators and Increment Operators
The output of the code is:
x=1 y=0
x=2 y = 0\
Explanation:\
- In the first line, the expression
!x || y++
is evaluated. The!x
returns 0 (false) since x is 1, so they++
part is not executed. Therefore, the value of x and y remain unchanged.\ - In the second line, the expression
!y && ++x
is evaluated. The!y
returns 1 (true) since y is 0, so the++x
part is executed and x becomes 2. Therefore, x is incremented and y remains unchanged.

原文地址: http://www.cveoy.top/t/topic/p3Lf 著作权归作者所有。请勿转载和采集!