Associativity of '==' and '!=' is left-right
1==5==5 will be solved as-
(1==5)==5
0==5 ('==' returns 0 to denote false)
0 [printf prints the number as it is]
1==5!=5 will be solved as-
(1==5)!=5
0!=5
1
Similarly, 1!=5!=5 will o/p 1 and 1!=5==5 gives o/p 0.