codegurukool.com · Free coding tutorials & online compiler

Home › COBOL Tutorial › COBOL get started

COBOL get started

Install GnuCOBOL, compile and run.

Install the free GnuCOBOL compiler (cobc). Save your program as hello.cob, build it with cobc -x hello.cob and run ./hello. The -x option makes an executable program.

Example code

      *> Terminal:
      *>   cobc -x hello.cob
      *>   ./hello
       IDENTIFICATION DIVISION.
       PROGRAM-ID. STARTED.
       PROCEDURE DIVISION.
           DISPLAY "It works".
           STOP RUN.

Run this code in the online editor

← COBOL installationCOBOL program structure →