CMSC 201

Lab 3: Simple Logic Programming

Comparators

What are they?

These allow you to compare two variables. If you want to see if one variable is larger than another, such as with two integers. They are usually used in decision statements such as an if statement.

What are the comparators?

This is a list of the most commonly used comparators. It is not an all-encompassing list.

  1. == equal to
  2. > greater than
  3. < less than
  4. >= greater than or equal to
  5. <= less than or equal to
  6. != not equal to
  7. not

All of these are used to compare two variables except "not" which is used on a single variable. Remember, string comparisons are case-sensitive.

Make sure the values you are comparing are of the same type or else the code will not act as you expect it to.