IDENTIFICATION DIVISION. PROGRAM-ID. reversestring. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-STRI PIC X(14) VALUE 'COBOL LANGUAGE'. 01 WS-STRO PIC X(14). 01 WS-I PIC 9(02) VALUE 0. 01 WS-J PIC 9(02) VALUE 1. 01 WS-LEN PIC 9(02) VALUE 0. PROCEDURE DIVISION. MOVE LENGTH OF WS-STRI TO WS-LEN. PERFORM VARYING WS-I FROM WS-LEN BY -1 UNTIL WS-I = 0 MOVE WS-STRI (WS-I:1) TO WS-STRO (WS-J:1) ADD 1 TO WS-J END-PERFORM. DISPLAY WS-STRI. DISPLAY WS-STRO. STOP RUN.
Write, Run & Share Cobol code online using OneCompiler's Cobol online compiler for free. It's one of the robust, feature-rich online compilers for Cobol language. Getting started with the OneCompiler's Cobol editor is easy and fast. The editor shows sample boilerplate code when you choose language as Cobol and start coding.