Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program on bubble sort method using cobol

Critics Rating:

Users Rating:

* PROGRAM ON BUBBLE SORT METHOD.

********************************

   IDENTIFICATION DIVISION.

   PROGRAM-ID.

   ENVIRONMENT DIVISION.

   DATA DIVISION.

   WORKING-STORAGE SECTION.

   01 ARRAY.

    02 A PIC 9(3) OCCURS 15 TIMES.

   77 N PIC 9(2).

   77 I PIC 9(2).

   77 J PIC 9(2).

   77 K PIC 9(2).

   77 C PIC 9(2).

   77 T PIC 9(3).

   77 P PIC ZZ9.

   PROCEDURE DIVISION.

   MAIN-PARA.

      DISPLAY "HOW MANY NUMBERS YOU WANT TO ENTER ?".

      ACCEPT N.

      MOVE N TO P.

      DISPLAY "ENTER " P " NUMBERS".

      PERFORM A-PARA VARYING I FROM 1 BY 1 UNTIL I > N.

      DISPLAY (1 , 1) ERASE.

      MOVE 0 TO COL.

      PERFORM X-PARA VARYING I FROM 1 BY 1 UNTIL I > N - 1.

      STOP RUN.

   A-PARA.

      ACCEPT A(I).

   X-PARA.

      MOVE 3 TO LIN.

      COMPUTE COL = COL + 15.

      DISPLAY (1 , COL) "PHASE-" I.

      PERFORM Y-PARA VARYING C FROM 1 BY 1 UNTIL C > N - I.

      PERFORM Z-PARA VARYING K FROM 1 BY 1 UNTIL K > N.

   Y-PARA.

      IF (A(C) NOT < A(C + 1))

       MOVE A(C) TO T

       MOVE A(C + 1) TO A(C)

       MOVE T TO A(C + 1).

   Z-PARA.

      COMPUTE LIN = LIN + 1.

      MOVE A(K) TO P.

      DISPLAY (LIN , COL) P.

Courtesy, Source, References & Regards: Kishore AVGK

While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright@2009-2011 by KuGuNi.com. All Rights Reserved.