Check if int is between two numbers

后端 未结 10 1011
夕颜
夕颜 2020-11-28 13:09

Why can\'t do you this if you try to find out whether an int is between to numbers:

if(10 < x < 20)

Instead of it, you\'ll have to do

10条回答
  •  萌比男神i
    2020-11-28 13:51

    if (10 < x || x < 20)

    This statement will evaluate true for numbers between 10 and 20. This is a rough equivalent to 10 < x < 20

提交回复
热议问题