Literal Example


Scenario - Explaining about different kinds of literals used in COBOL programming.

Code -

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

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-VAR.
          05 WS-ALPHAB       PIC A(15) VALUE "ALPHABETIC".
          05 WS-ALPHA-NUM    PIC X(15) VALUE "ALPHA NUMERIC3".
          05 WS-NUMRIC       PIC 9(03) VALUE 100.

       PROCEDURE DIVISION.
           DISPLAY WS-VAR.
           STOP RUN.

Explaining Example -

In the above example:

  • "ALPHABETIC" is the alphabetic literal.
  • "ALPHA NUMERIC3" is the alpha-numeric literal.
  • 100 is the numeric literal.