Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute COBOL Online

IDENTIFICATION DIVISION.
PROGRAM-ID. MPROG20.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE Section.
01 WS-Name pic X(10) values spaces.
01 WS-Number pic 99 values Zero.
01 WS-inputedDate.
    03 WS-inputedDay pic 9(2).
    03 WS-inputedMonth pic 9(2).
    03 WS-inputedCenturies pic 9(2).
    03 WS-inputedYear pic 9(2).
01 WS-Command pic 9 values zero.
01 WS-temp pic 99 values zero.
01 WS-multipleResult pic 99 values zero.
01 WS-CURRENT-DATE-DATA.
    05  WS-CURRENT-DATE.
        10  WS-CURRENT-YEAR         PIC 9(04).
        10  WS-CURRENT-MONTH        PIC 9(02).
        10  WS-CURRENT-DAY          PIC 9(02).
01 WS-inputedIntergerDate pic 9(8).
01 WS-currentIntergerDate pic 9(8).
PROCEDURE DIVISION.
    Perform 100-MENU.
    STOP RUN.

100-MENU SECTION.
110-START.
    DISPLAY '1. Say Hello funtion'.
    DISPLAY '2. Multiple'.
    DISPLAY '3. Different date'.
    DISPLAY '4. Exit'.
    Perform 200-SAY-HELLO.
190-END.

200-SAY-HELLO SECTION.
210-START.
    move 'PhucLH9' to WS-Name.
    DISPLAY 'Hello ' WS-Name.
    Perform 300-Multiple.
    Perform 400-Different-date.
290-END. 
    EXIT.

300-Multiple SECTION.
310-Start.
    move 3 to WS-Number.
    move 1 to WS-temp.
320-Multiple.
    Compute WS-multipleResult = WS-temp * WS-Number.
    DISPLAY WS-Number 'x' WS-temp '=' WS-multipleResult.
    Add 1 to WS-temp.
    if WS-temp < 11
       Perform 320-Multiple
    end-if.
390-END. 
    EXIT.

400-Different-date SECTION.
410-START.
    move '02112016' to WS-inputedDate.
    move FUNCTION CURRENT-DATE to WS-CURRENT-DATE-DATA.
    Compute WS-currentIntergerDate = FUNCTION INTEGER-OF-DATE(WS-CURRENT-DATE-DATA(1:8)).
    DISPLAY WS-CURRENT-DATE-DATA(1:8).
    DISPLAY WS-inputedCenturies WS-inputedYear '/' WS-inputedMonth '/' WS-inputedDay.
490-END.
    EXIT.















Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.