COBOL - Relation Condition
A general relation condition compares two operands, either of which can be an identifier, literal, arithmetic expression, or index-name.
Syntax:
Where,
operand-1 and operand-1 - The subject of the relation condition. Can be an identifier, literal,function-identifier, arithmetic expression, or index-name.
Relational operator | Can be written | Meaning |
IS GREATER THAN | IS > | Greater than |
IS NOT GREATER THAN | IS NOT > | Not greater than |
IS LESS THAN | IS < | Less than |
IS NOT LESS THAN | IS NOT < | Not less than |
IS EQUAL TO | IS = | Equal to |
IS NOT EQUAL TO | IS NOT = | Not equal to |
IS GREATER THAN OR EQUAL TO | IS >= | Is greater than or equal to |
IS LESS THAN OR EQUAL TO | IS < | Is less than or equal to |
Example: 1
IDENTIFICATION DIVISION.
PROGRAM-ID. COBRELAC.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(9).
01 B PIC 9(9).
PROCEDURE DIVISION.
A000-FIRST-PARA.
MOVE 15 TO A.
MOVE 20 TO B.
IF A IS GREATER THAN OR EQUAL TO B THEN
DISPLAY 'A IS GREATER THAN B'
ELSE
DISPLAY 'A IS LESS THAN B'
END-IF.
STOP RUN. |
When you compile and execute the above program, it produces the following result −
Output :
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!