If statement executing even when conditionals are false.

GolamMostafa:
This is semantically correct; is it syntactically correct from programming point of view?

You got that exactly wrong @GolemMostafa.
If it were syntactically incorrect, a C compiler would complain.
But, because the syntax is correct, it won't.

However, the semantics are wrong, because of the language's operator precedence, and left-to-right evaluation.
if (250 < lightlevel < 800) is evaluated as "is 250 less than lightlevel? (answer: true or false)"
Because true is equivalent to 1, and false to zero, the evaluation proceeds
"is 0 (or 1) less than 800? (anwer: true or false)" which is, of course, always true.