Wednesday, January 21, 2009

if-else equalities

For if-else statements:
  • == represents "EQUAL"
    -if a is EQUAL to b:
    eg: if(a == b) {...}
  • != represents "NOT EQUAL"
    -if a is NOT EQUAL to b:
    eg: if(a != b) {...}
  • < represents "LESS THAN"
    -if a is LESS THAN b:
    eg: if(a < b) {...}
  • <= represents "LESS THAN OR EQUAL"
    -if a is LESS THAN OR EQUAL to b:
    eg: if(a <= b) {...}
  • > represents "MORE THAN"
    -if a is MORE THAN b:
    eg: if(a > b) {...}
  • >= represents "MORE THAN OR EQUAL"
    -if a is MORE THAN OR EQUAL to b:
    eg: if(a >= b) {...}
  • || represents "OR"
    - if I am going to japan OR going to america, i scan 10 fingers:
    eg: if(dest=="japan" || dest=="america") {...}
  • && represents "AND"
    - if I have more than $5 AND today is tuesday, I will eat KFC meal:
    eg: if(money>5 && day=="tue") {...}

No comments:

Post a Comment