Arithmetic inside an if statement

The concept you need is "expression". A comparison is already an expression, so incorporating arithmetic into the expression is also allowed.

By the way, comparison operators have low precedence, so the subtractions don't need parentheses.