EXIT Statement


EXIT statement is a "do-nothing" statement mainly used for readability and structure, giving a logical endpoint for a section or paragraph.

Syntax -

paragraph-name. 
    EXIT.

Notes -

It is used to -

  • Indicate the end of a paragraph that may be used as a logical exit or termination point in the program.
  • Mark the end of a section within the PROCEDURE DIVISION, mainly when the section is intended to contain multiple paragraphs but currently has none.

EXIT improves the clarity and structure of the code, making it easier for other developers to understand the flow of the program.

Practical Example -


Scenario - EXIT usage in paragraph.

----+----1----+----2----+----3----+----4----+
       ...
       PROCEDURE DIVISION.
           PERFORM 1000-DISPLAY
              THRU 1000-EXIT.
           STOP RUN.
       ...
       1000-DISPLAY.
           DISPLAY "PARAGRAPH EXIT EXAMPLE". 
       1000-EXIT.
           EXIT.