Words Example


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

Code -

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

       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       01 WS-VAR        PIC X(15) VALUE "HELLO WORLD". 
	   
       PROCEDURE DIVISION.
           DISPLAY WS-VAR.
           STOP RUN.

Explaining Example -

In the above example:

  • WORDEX is the program name (user-defined word) provided by the programmer.
  • MTH is the author name (user-defined word) which is a IDENTIFICATION DIVISION comment.
  • WS-VAR are variable or data item.
  • The words that are highlighted in Red color are reserved words.