Menu
CoddyTech

DISPLAY Several Items

Part of the First Programs section of Coddy's COBOL Programming journey. Lesson 10 of 19.

One DISPLAY prints several items side by side, in the order they are written:

DISPLAY "Total: " TOTAL.

Nothing is added between items. Put the spaces you want inside the literals: "Total: " ends with one.

A field always prints at its full size, so a PIC X(8) holding Ada prints Ada and five spaces before the next item.

A long statement can go on over several lines. COBOL reads it up to the period:

DISPLAY "Name: " FIRST-NAME
    " " LAST-NAME.
challenge icon

Challenge

Easy

Display Name: Grace Hopper with one DISPLAY that uses FIRST-NAME and LAST-NAME.

Try it yourself

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEVERAL.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 FIRST-NAME PIC X(5) VALUE "Grace".
       01 LAST-NAME PIC X(6) VALUE "Hopper".
       PROCEDURE DIVISION.
           *> Display the name here
           STOP RUN.
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in First Programs