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

后端 未结 2 1621
有刺的猬
有刺的猬 2020-12-07 06:35
#include 
int main(void)
{
   int i=10;
   if(i==(20||10))
       printf(\"True\");
   else
       printf(\"False\");
   return 0;
}

2条回答
  •  不知归路
    2020-12-07 06:55

    look at if(i==(20||10)). Due to the inner parentheses, 20||10 is evaluated first, yielding 1. Then, variable i, whose value is 10 is compared to 1, resulting 0.

    In C, and 0 stands for False, while all non-zero values means True. So the condition comes to be False. Thus, "False" is printed.

提交回复
热议问题