Printf even though it shouldn't

后端 未结 2 1645
梦谈多话
梦谈多话 2021-01-28 08:15

I have this part of an if statement and I\'m getting a weird output.

int x = 10;

if(1 < x < 5){
    printf(\"F\\n\");
}

Why does it prin

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 08:35

    If you are using C, you should have broken down the condition into two arguments :

        if ( x > 1 && x < 5) {
            printf("F\n");
        }
    

提交回复
热议问题