COBOL by Example: Hello World
Writing your first COBOL program to display text output on the console, understanding the mandatory IDENTIFICATION DIVISION with PROGRAM-ID paragraph, implementing executable logic in the PROCEDURE DIVISION with the DISPLAY statement for output, and terminating program execution properly with STOP RUN to return control to the operating system.
Code
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, World!'.
STOP RUN.Explanation
Every COBOL program starts with the IDENTIFICATION DIVISION, which serves as the program's identity card. It must contain the PROGRAM-ID paragraph, which specifies the program's name as known to the operating system. This division is the only truly mandatory division in COBOL and is always the first section of code in any standard COBOL program.
The PROCEDURE DIVISION is where the actual work happens. It contains the executable instructions (statements) that the computer follows. COBOL syntax is designed to be English-like, making it readable even to non-programmers. This example demonstrates the DISPLAY statement, which outputs text to the standard output device (usually the terminal or console
). String literals in COBOL can be enclosed in either single quotes or double quotes, depending on compiler preferences.
Finally, the STOP RUN statement is crucial. It acts as the termination command, telling the operating system that the program has finished its execution and control should be returned. Without this, the program might not exit correctly or could fall through to unintended code in larger applications. This is the standard way to exit a main program in COBOL.

