Why are numbers compared incorrectly?

printf("%i\n",6==1==0); //1, а по идее должно быть 0, так как не равны printf("%i\n",0==0==0); //0, по идее 1 

    2 answers 2

     6==1==0 

    performed as

     (6==1)==0 

    Since 6==1 is false, the calculation of this value gives 0, which when compared with 0 gives true, i.e. one.

    Take the second example yourself - as (0==0)==0 .

    • aa, I understood, and how best to compare them? - alex-rudenkiy 1:09 pm
    • or only (a == b) == (b == c) == (a == c)? - alex-rudenkiy 1:09 pm
    • five
      (a == b) && (b == c) - Igor

    Operands are evaluated in turn:

    (6==1)==0 ,

    (0==0)==0