Unconditional GO TO Example


Scenario - Passing control to a END-PARA unconditionally.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. UNCDGOTO.
       AUTHOR. MTH.

       PROCEDURE DIVISION.
       BEGIN-PARA.
           DISPLAY 'Start'.

           GO TO END-PARA.
           DISPLAY 'This will be skipped'.

       END-PARA.
           DISPLAY 'End'.
           STOP RUN.

Output -

Start
End

Explaining Example -

In the above example:

  • Program execution starts at display. Once the GO TO statement executed, control transferred to END-PARA unconditionally.
  • After the END-PARA execution completed, control returns to the system.