codegurukool.com · Free coding tutorials & online compiler

Home › COBOL Tutorial › COBOL DISPLAY

COBOL DISPLAY

Print text and values.

DISPLAY prints literals and variables one after another. Text goes in quotes. SPACE is a figurative constant for a blank. Add WITH NO ADVANCING to stay on the same line.

Example code

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SHOW.
       PROCEDURE DIVISION.
           DISPLAY "Line 1".
           DISPLAY "Total: " 42 " items".
           DISPLAY "A" SPACE "B".
           DISPLAY "No newline" WITH NO ADVANCING.
           DISPLAY " - continued".
           STOP RUN.

Run this code in the online editor

← COBOL format and commentsCOBOL variables and PICTURE →