Relation Condition

A relation condition is used to compare two operands. It results in 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 and operand-2 - operand-1 is a variable that we want to compare. operand-2 is a variable or literal that is to be compared with. They can be numeric or alphanumeric, but both operands must 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'
    DISPLAY 'Income less than 100000'


Income greater than 100000

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

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

OUTPUT -He is eligible for vote