为什么像 (0 < a < 5) 这样的条件总是正确的? [英] Why is a condition like (0 < a < 5) always true?
本文介绍了为什么像 (0 < a < 5) 这样的条件总是正确的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用 C 实现了以下程序
I implemented the following program in C
#include <stdio.h>
int main()
{
int a = 10 ;
if(0 < a < 5)
{
printf("The condition is true!") ;
}
return 0 ;
}
为什么条件0总是返回
true
?
推荐答案
因为 a0
计算结果为 1
.
用途:
a >0&&一个<5
如果要测试a
是否大于0
且小于5
.
if you want to test if a
is greater than 0
and lower than 5
.
这篇关于为什么像 (0 < a < 5) 这样的条件总是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文