User Input and Display

   IDENTIFICATION DIVISION.
   PROGRAM-ID. USER-INPUT.

   DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 USER-NAME   PIC A(20).

   PROCEDURE DIVISION.
   DISPLAY "ENTER YOUR NAME: ".
   ACCEPT USER-NAME.
   DISPLAY "HELLO, " USER-NAME.
   STOP RUN.</code></pre>

Explanation:

PIC A(20) → allows up to 20 alphabetic characters.

ACCEPT USER-NAME → takes input from user.

DISPLAY → prints greeting with input.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *