为什么像 (0 < a < 5) 这样的条件总是正确的? [英] Why is a condition like (0 < a < 5) always true?

查看:16
本文介绍了为什么像 (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?

推荐答案

因为0

a 计算结果为 1.

用途:

a >0&&一个<5

如果要测试a是否大于0且小于5.

if you want to test if a is greater than 0 and lower than 5.

这篇关于为什么像 (0 &lt; a &lt; 5) 这样的条件总是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆