void main int a = 1 b = 2 m = 0 n = 0 k; k = n=bam=ab; printfk = dm = dnkm;
The output of this program is:
k = 1, m = 1
Explanation:
-
The variables a, b, m, n are initialized to 1, 2, 0, 0 respectively.
-
The expression (n=b>a)||(m=a<b) is evaluated using the OR operator ||.
-
The sub-expression b>a is true (since 2 is greater than 1), so the assignment n=b>a sets n to 1 (true).
-
Since the OR operator short-circuits, the second sub-expression (m=a<b) is not evaluated, and k is assigned the value of the first sub-expression (i.e. 1).
-
Finally, m is assigned the value of a<b, which is also true (since 1 is less than 2), so m is set to 1.
-
The printf statement outputs the values of k and m, which are 1 and 1 respectively.
原文地址: https://www.cveoy.top/t/topic/bzIe 著作权归作者所有。请勿转载和采集!