I\'ve done my programming exam in C yesterday. There was a question I could not answer, and even though I\'ve studied today I can\'t come up with a solution.
So we h
This question should never be on an exam, because it contains undefined behavior.
Specifically, this assignment A = (~C) - A--
modifies A
twice - in the --
compound assignment, and in the assignment itself. Since there is no sequence point in between the two, the behavior is undefined.
Note: This does not mean that the program is not going to print anything. It would most definitely produce some output on most platforms. However, none of that matters, because C the program is invalid in its entirety: it can produce any output it chooses to, produce no output, or even crash.