You can't string logical comparisons together like that.

To understand why, you have to understand exactly what those operators are doing.

Every time you do something like

a < b

the result is 1 if the expression is true and 0 if the expression is false.

If you, in turn, try to do

a < b < c

then a < b will evaluate to either a 1 or a 0 (true or false), and then that 1 or 0 will be compared with c.

What you really want to do is use the logical AND operator which is &&

a < b && b < c // a is less than b AND b is less than c

however, in this case, there is a better way of accomplishing what you want:

Code:

if( a > b )
if( a > c )
max = a;
else
max = c;
else
if( b > c )
max = b;
else
max = c;

or, if you want to learn the ?: operator, it can also be done like this

max = ( a > b ? ( a > c ? a : c ) : ( b > c ? b : c ) );