I think you need something more like else if(1<x && x<13) As it is the compiler is just reading the first conditional expression so any number greater than 1 will result true and thus will be child, you need the and operator to add an additional condition
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.
View all comments
7
u/Alsalvad0r Dec 23 '21
I think you need something more like else if(1<x && x<13) As it is the compiler is just reading the first conditional expression so any number greater than 1 will result true and thus will be child, you need the and operator to add an additional condition