$ cat hello.cob
* 循环语句
* cobc -x -o hello hello.cob
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-CNT PIC 9(1) VALUE 0.
PROCEDURE DIVISION.
A-PARA.
PERFORM B-PARA WITH TEST AFTER UNTIL WS-CNT>3.
STOP RUN.
B-PARA.
DISPLAY 'WS-CNT : 'WS-CNT.
ADD 1 TO WS-CNT.
运行:
$ cobc -x -o hello hello.cob
$ ./hello
WS-CNT : 0
WS-CNT : 1
WS-CNT : 2
WS-CNT : 3