COBOL–Working storage variables

Working Storage section comes under DATA division. Different datatypes of COBOL are explained here.

Below sample cobol program declares and Displays a working storage variable named ‘MY-STRING’.

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       IDENTIFICATION DIVISION.                        
       PROGRAM-ID.    KARTEST3.                        
      * define and use a working storage variable      
       ENVIRONMENT DIVISION.                           
       DATA DIVISION.                                  
       WORKING-STORAGE SECTION.                        
        01 MY-STRING  PIC X(20) VALUE 'HELLO WORLD ! '.
       PROCEDURE DIVISION.                             
           DISPLAY MY-STRING.                          
           GOBACK.

Output of this program will be

HELLO WORLD !
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.