COBOL stands for Common Business-Oriented Programming Language, which is one of the oldest and first high-level programming languages. It is mostly used for the defense and insurance domains which require huge data processing.
Features of COBOL: It is a business-oriented and robust language Provide good file handling methods Excellent self-documenting capabilities Structured Programming language 👁 Structure of COBOL Divisions A COBOL program basically divided into the following four divisions:
Identification division Environment division Data division Procedure division Identification Division: This is the first and the compulsory division of every COBOL program. In this division, the details like author name, date of execution, date of writing the code, installation, etc. can be mentioned. Syntax:
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM-NAME.
[AUTHOR. Comment Entry]
[INSTALLATION. Comment Entry]
[DATE-COMPILED. Comment Entry]
[DATE-COMPILED. Comment Entry]
Environment division: Using this environment division we can specify the program features which are dependent on the system running it. Environment division is used to specify, the computer environment in which the program is written and executed. Environment division is further divided into two types:Configuration Section: Identifies the computer used for compiling programs.Input- Output Section: Identifies the files and the input-output resources used by the program. Syntax:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
[FILE-CONTROL. ]
[ File control entries ]
[ I - O CONTROL. ]
[ I- O Control entries ]
Data Division: The data division is used to declare variables and parameters in the COBOL program. In Data division we declare the variables, their data type, size, usage type, etc. Data division is optional unless the program manipulates any constant and user-defined data. DATA DIVISION has three different sections, which is mentioned below:FILE SECTION : describe most of the data that is sent to, or coming from, the computer's peripherals.WORKING-STORAGE SECTION : Describes the general variables used in the programLINKAGE SECTION : Establishes a link between two programs Procedure Division: This is the main division in the COBOL programming language, where business logic has to be written. Procedure Division contains user-defined Sections, Paragraphs, Sentences, Statements, Clauses, and Verbs. Statements and sentences are necessary for reading input, processing it, and writing the output. All the data described in the DATA DIVISION are processed here and desired results are produced. Should contain at least one paragraph, sentence, and statement only the Section is an option. Example 1:
Output:
👁 Image Explanation:
In this program, we are displaying the uses and performance of the 4 different kinds of COBOL division. Which we discussed in this article. Identification division is used to display author details. Environment division is used to display, source computer details, and object computer details. As well as input-output files details we have to mention under this division only. Data division is used to introduce all the variables before using them in the procedure division Procedure division is used to write the main part of the program and its functionality.