ACCEPT and DISPLAY
Problem Description
Write a program that accepts user name and displays a personalized greeting.
Expected Output
Input: John -> Output: Hello, John! Welcome!
Hints
Use ACCEPT for input and DISPLAY for output.
Solution
IDENTIFICATION DIVISION.
PROGRAM-ID. GREETING.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(20).
PROCEDURE DIVISION.
DISPLAY "ENTER YOUR NAME: ".
ACCEPT WS-NAME.
DISPLAY "HELLO, " WS-NAME "! WELCOME!".
STOP RUN.
Explanation:
ACCEPT reads from terminal, DISPLAY writes to terminal.