Chapter 4 Challenge


I was just thinking about the challenge listed in this chapter

In particular I was considering this line:

[quote]if (5 < j - k) { // first expression
printf(“The first expression is true.”);

We already know that the value of “j” is 25.
The value of “k” is either 10 or 5 (although in this case it is 5 as “i” is not greater than “j”). Which means this j-k is always greater than 5 (it is either 15 or 20).

This means that the output of this program is “The first expression is true.”

The only reason I bring up this point is that as this challenge is more of a thought experiment, there is some scope for a reader to incorrectly interpret “int k = (i > j) ? 10 : 5;” and still come up with the right answer when they run the program.

Is this the case or have I myself misinterpreted the question?


You are correct.

Run the program for verification.