-6

I'm trying to compare values in an if statement, but it keeps coming out wrong. Basically what I'm trying to do logically is if (a <= b < c){ //do stuff however I find that a <= b returns either a 0 or a 1 which will always be less than c. All I can think of is what's below but I don't know if that's correct or the simplest way.

if (a <= b == 1 and b < c == 1){ 
// do stuff

Thank you

Justin
  • 165
  • 3
  • 14
  • Note [and instead of &&](http://stackoverflow.com/q/17365271/1708801) is valid if rarely used. – Shafik Yaghmour Nov 07 '14 at 22:01
  • Don't use `and` - use `&&` for a logical and operation. `and` is in place only for keyboards where typing `&&` is not possible. – xxbbcc Nov 07 '14 at 22:03

1 Answers1

2

Do this and please learn the usage of operators beforehand.

if(a<=b && b<c) {
     //do stuff
}
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
saruftw
  • 1,104
  • 2
  • 14
  • 37