C Programming: Understanding Complex Expressions in printf
The output of this program is:
3,1,1,1
Explanation:
- The first parameter in the printf statement is the result of the expression 'a = b = c'. This means that the value of 'c' is assigned to both 'b' and 'a', and then the value of 'c' (which is 3) is printed. So the first output is 3.
- The second parameter is the result of the expression 'a=b==c'. This means that the value of 'b' is compared to 'c', and the result (which is true, since 'b' is equal to 'c') is assigned to 'a'. So the second output is 1.
- The third parameter is the result of the expression 'a==(b=c)'. This means that the value of 'c' is assigned to 'b', and then the value of 'a' (which is 3) is compared to the new value of 'b' (which is also 3). Since they are equal, the result is true, and this value (which is 1) is printed.
- The fourth parameter is the result of the expression 'a==(b==c)'. This means that the value of 'b' is compared to 'c', and the result (which is true) is compared to the value of 'a' (which is also true, since 'a=b=c'). So the fourth output is also 1.
原文地址: https://www.cveoy.top/t/topic/oHIm 著作权归作者所有。请勿转载和采集!