Beware of coma (and comma)

Consider the following code:

if you run it it will print:

The problem here is the extra comma in the if statement:

It is not a compilation error, instead the compiler parses it as 2 statements: x>30 and 400

The if statement is checking only the last statement and because 400 is true , it will always be true (no matter what x value is)


Always check compiler warnings , make it display all warnings (-Wall) and use static analysis tools