Code for Program of bubble sort in Cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. PRG1.
DATA DIVISION.
77 ARR OCCURS 5 TIMES PIC S9(2).
77 TEMP PIC 999 VALUE 000.
77 I PIC 9 VALUE 0.
77 J PIC 9 VALUE 1.
PROCEDURE DIVISION.
DISP.
DISPLAY "ENTER ANY FIVE NUMBERS:"
PERFORM UNTIL I = 5
ADD 1 TO I
ACCEPT ARR(I)
END-PERFORM.
MOVE 1 TO I.
PERFORM UNTIL I > 5
MOVE I TO J
PERFORM UNTIL J > 5
IF (ARR(I) > ARR(J))
MOVE ARR(I) TO TEMP
MOVE ARR(J) TO ARR(I)
MOVE TEMP TO ARR(J)
END-IF
ADD 1 TO J GIVING J
END-PERFORM
ADD 1 TO I GIVING I
END-PERFORM.
MOVE 0 TO I.
PERFORM UNTIL I = 5
ADD 1 TO I
DISPLAY I ":=" ARR(I)
END-PERFORM.
STOP RUN.
ENTER ANY FIVE NUMBERS:
78
23
45
56
21
AFTER SORTING:
21
23
45
56
78