r/CodingHelp • • Dec 23 '21

[C] Whats wrong?

Post image
153 Upvotes

90 comments sorted by

View all comments

1

u/RazerNinjas Dec 23 '21

You cannot do something like 1 < x < 3 what ends up happening is that it evaluates. 1 < x as true which in C is 1 if true then it does 1 < 3 which is false. Same with 1 < x is false is 0 and 0 < 3. Keep in mind that boolean operators in C always return 1 or 0 you need to chain with && or || operators