Navigate Condition in COBOL

Navigate Condition

  • This condition is stated by using the NOT keyword.
  • If NOT is given in front of condition and condition is true, then the output of the condition will be false.
Navigate condition syntax is:
IF NOT [CONDITION]
    COBOL Statements
END-IF.

Example : Program to demonstrate navigate condition

IDENTIFICATION DIVISION.
PROGRAM-ID. NC.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 N1 PIC 9(2) VALUE 65.
   01 N2 PIC 9(3) VALUE 89.

PROCEDURE DIVISION.
   A000-FIRST-PARA.
   
   IF NOT N1 IS GREATER THAN N2 THEN
      DISPLAY 'IF-BLOCK'
   ELSE
      DISPLAY 'ELSE-BLOCK'
   END-IF.
   
STOP RUN.


Output:
IF-BLOCK