int main() { int k = 1, j = 2, l=0,o; o = k + j || l++; } I went through the debugger, but didn’t understand why the variable о saves the value 1?
int main() { int k = 1, j = 2, l=0,o; o = k + j || l++; } I went through the debugger, but didn’t understand why the variable о saves the value 1?
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
The expression (k + j) || (l++) (k + j) || (l++) is a logical expression with the result true . When casting to int type, the value true becomes 1 . You can see it.
The expression has the result true already because to the left of the operator || there is a nonzero value of k + j . Non-zero integer values in a logical context act as true . Since the left operand || is true , then the result is true . Right operand || it will not even be calculated, i.e. l keep the value 0 .
Source: https://ru.stackoverflow.com/questions/919285/
All Articles
ohave no definite value at all. How can she "save" him? - AnT