This is a sample program that displays "Hello World":
---- hello.cob ------------------------- * Sample COBOL program IDENTIFICATION DIVISION. PROGRAM-ID. hello. PROCEDURE DIVISION. DISPLAY "Hello World!". STOP RUN. ----------------------------------------
The compiler is cobc
, which is executed as follows:
$ cobc hello.cob $ ./hello Hello World!
The executable file name (i.e., hello
in this case) is
determined by removing the extension from the source file name.
You can specify the executable file name by specifying the compiler
option -o
as follows:
$ cobc -o hello-world hello.cob $ ./hello-world Hello World!