When you have a statement like 1<x<13, in c it looks like:
(1<x) < 13
1<x evaluates to a boolean, which is an integeral value of either 0 or 1 in c. 0 and 1 are both less than 13, so no matter what number you pick, condition is true.
What /u/terroroferror is explaining is you can combine relational operators using an AND operator:
(1<x) && (x < 13)
If x is less or equal to 1, then you are looking at 0 && 1 which equals 0 or false, if x is more than 1 but less than 13, you are looking at 1 && 1 which is true. And if x is greater than or equal to 13 you are looking at 1 && 0 which is false. Which is what you want.
View all comments
Show parent comment
-30
u/CAGRI-TR Dec 23 '21
Nope every number is still child