Monday, January 11, 2010

Relation Operator

Relation Operator is used to compare two statements, especially in a decision.
There will be a value (true or false), according to the statements comparison.
Then the decision is work according to these values (true or false), whether it will run the statement or not, or run another statement.

There are some relation operators:
  • > : statement on the left operator is upper than the statement on the right
  • >= : statement on the left operator is upper or the same as the statement on the right
  • < : statement on the left operator is lower than the statement on the right
  • <= : statement on the left operator is lower or the same as the statement on the right
  • == : statement on the left operator is the same as the statement on the right
  • != : statement on the left operator is not the same as the statement on the right

See the example below:

  • 9 > 8 has TRUE value
  • 2 > 6 has FALSE value
  • 50 != 64 has TRUE value
  • (10x5) != 50 has FALSE value
  • (4 + 2) <= (3x2) has TRUE value
  • (4 + 1) <= (3x2) has TRUE value
  • 6/9 >= 5/9 has TRUE value
  • 6/9 >= 8/9 has FALSE value

To see how these values being used in a decision, open the next post with the title is Decision using IF and Else.


0 comments:

Post a Comment