c - How is i==(20||10) evaluated? -


#include <stdio.h> int main(void) {    int i=10;    if(i==(20||10))        printf("true");    else        printf("false");    return 0; } 

this gives output false.

please explain me how program work?

this line if(i==(20||10)) evaluates i==1 alk said in comments - (20||10) evaluates 1, hence when compare i == 1, why false output. non-zero value in c implies true.

read short-circuit evaluation

perhaps wanted:

int i=10; if(i==20 || == 10)     printf("true"); else     printf("false"); 

Comments