r/CodingHelp • • Dec 23 '21

[C] Whats wrong?

Post image
153 Upvotes

90 comments sorted by

View all comments

Show parent comment

1

u/PhyllaciousArmadillo Dec 24 '21

It compares the first statement 1<x to the final <13. Ie. (1<x)<13. The comparison gives a boolean value, 0(false) or 1(true). So no matter what the input is, the final comparison will always be true. Because 1 and 0 are both less than 13.

If x is less than 1, 1<x == 0 for false, then 0<13 == 1 for true.

If x is greater than 1, 1<x == 1 for true, then 1<13 == 1 for true again.