Relation Condition


  • A relation condition compares two operands using relational operators (=, >, <, <=, >=, <>) and returns a boolean value of TRUE or FALSE.
  • These conditions are important for making decisions in the program, such as controlling the flow of execution using the IF, EVALUATE, or PERFORM ... UNTIL statements.

Syntax -

operand-1 relational-operator operand-2

Parameters -

  • operand-1 - operand-1 is a variable that we want to compare.
  • operand-2 - operand-2 is a variable or literal that is to be compared with.
Tip! These operands can be numeric or alphanumeric. However both operands should be of the same type or compatible types for the comparison to be meaningful.

Relational Operators -

  • Equal to - =
  • Greater than - >
  • Less than - <
  • Greater than or equal to - >=
  • Less than or equal to - <=
  • Not equal to - NOT =

Examples -


Scenario1 - Salary 200000 comparison.

IF WS-SALARY > 100000
    DISPLAY 'Income greater than 100000'
ELSE
    DISPLAY 'Income less than 100000'
END-IF.

OUTPUT -

Income greater than 100000

Scenario2 - Compare the age (22) check the eligibility for vote.

IF WS-AGE > 18 
    DISPLAY 'Eligible for vote'
ELSE
    DISPLAY 'Not eligible for vote'
END-IF.

OUTPUT -He is eligible for vote