COBOL Tutorial: What Is COBOL Programming Language?
COBOL Tutorial: What Is COBOL Programming Language?
Programming Language?
ByBarbara ThompsonUpdatedMay 18, 2022
What is COBOL?
COBOL is a programming language that is mainly focused on solving a business
problem. Full form of COBOL is Common Business-Oriented Language. It is
primarily used in company and government business, finance, and administrative
systems. This language also used as a solution to many data processing problems.
What is COBOL?
Features of COBOL
History of COBOL
How to Install COBOL on Windows 10
COBOL Program Structure
Types of Divisions
COBOL coding rules
The standard form of Cobol program
Program Syntax Rules of COBOL
Variables in COBOL
If Else Statements:
Example of COBOL
Advantages of COBOL
Disadvantages of COBOL
Top COBOL Interview Questions and Answers
Features of COBOL
Here, are some most important features of the COBOL programming language:
Allows you to handle a considerable volume of data due to its advanced file
managing capability.
Logical structure in COBOL is easier to read and modify.
It can be executed and compiled on machines like IBM, personal computers,
etc.
Testing and debugging tools are always accessible on all platforms of the
computer. Therefore, it is a robust programming language.
You can easily debug in COBOL as it has different divisions.
COBOL was designed for business-oriented applications. It can handle large
volumes of data due to its advanced file handling capabilities.
History of COBOL
Here, are important landmarks from the history of COBOL:
Hercules is one of the popular COBOL emulators which can easily installed on
Windows. Hercules is an open-source tool. It works on the latest 64-bit
z/Architecture.
1. Select the radio button accept the term the Licence Agreement
2. Click on Next Button
Step 5) Click on Install
In the next screen, click on Install button.
Step 6) Click on Install button
Click Install to begin the installation
COBO
L Programming structure
Here, are various components of the COBOL program:
Divisions
A division is a block of code, which usually contains one or more sections. It starts
where the division name is encountered. It ends with the beginning of the next
division.
Sections
Sections are the logical subdivision of the program logic. It is the collection of
paragraphs.
Paragraphs
Paragraphs are the portion of a selection which is a user-defined or predefined
name which should be followed by a period. This section includes zero or more
sentences.
Sentences
Sentences are a combination of single or multiple statements. They should occur
only in the procedure division. A sentence in COBOL language must end with a
period(.).
Statements
These are the meaningful COBOL statements which perform some processing.
Characters
These are the lowest in the hierarchy which cannot be divided.
Types of Divisions
Various divisions in COBOL program structure are as follows:
Identification Division
Environment Division
Data Division
Procedure Division
Identification Division
The programmer and compiler can use this division to recognize the
program.
The only compulsory division is Program ID.
It identifies the name of the program which contains characters.
Environment Division
It helps you to identify input and output files to the program.
Configuration section:
This section gives information regarding the system on which the program is
written and run.
Input-Output sections:
This section gives detail related to files which are used in the program.
File section – Allows you to define the record structure of the file.
Working storage section: This section helps you to declare the temp
variables and file structures.
Local-storage section: This section is the same as the local working storage
section. The key difference between the two is that variables must be
initialized every time when the program starts execution.
Linkage section: This section describes the data names received from the
external storage.
Procedure Division:
This division is used for including the logic of the program.
Procedure division also includes executable statements which are defined in
the data division.
The first six character positions are allocated for sequence numbers.
The seventh character position is reserved for the continuation character, or
for an asterisk which denotes a comment line.
The actual real program text starts with column 8.
The fourth positions from 8 to 11 are known as Area A, and positions from 12
to 72 are called Area B.
COBOL has syntax, which is very similar to the English language, that was
designed to be self-documenting and very readable.
Example: y = x; is represented with: MOVE x TO y
It is not a case sensitive language.
It has more than 300 reserved words
Complex conditions can be “abbreviated” by removing repeated variables
and conditions. For example:
IS a GREATER THAN x AND y GREATER THAN OR EQUALS To
It lacks big size standard library, as it has only 43 statements, 87 functions,
and just one class.
Variables in COBOL
In COBOL variable is a named location in memory into which a program can put
data and from which it can retrieve data. A data-name or identity. It is the name
used to identify the area of memory that is reserved for the variable.
Variables must be described in terms of their size and type. Every variable used in a
COBOL program should have encryption in the DATA DIVISION.
If Else Statements
In COBOL, If else statement is used for conditional branching
The relational operators and some spelled out phrases can be used
Greater than, less than, equal to are the spelled out phrases
Evaluate X
When 1 perform action1
When 2 perform action2
When 3 perform action3
When others perform action4
End-evaluate
If no condition is matched, then the other clause is executed. This is quite similar to
the switch statements in other languages.
Example of COBOL
Example 1 – Hello World!
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, world.'
STOP RUN.
Advantages of COBOL
Here, are important cons/benefits of using COBOL language:
Disadvantages of COBOL
Here, are some cons/disadvantages of using COBOL: