Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program describes sorting technique

Posted By: Courtney Hughes     Category: Cobol     Views: 2519

Program describes sorting technique.

Code for Program describes sorting technique in Cobol

#--------------------------------------------------------------------------------#

                INPUT FILE - SORT.INP
            
#--------------------------------------------------------------------------------#

prem     15
harshad  17
khilan   42
krish    44
hemal    74
shashank 72
nita     34
amisha   01
gediya   10
vd       06

#--------------------------------------------------------------------------------#

                CODE FILE - SORT.CBL
            
#--------------------------------------------------------------------------------#

       IDENTIFICATION DIVISION.
        PROGRAM-ID. SORT1.

       ENVIRONMENT DIVISION.

        CONFIGURATION SECTION.
         SOURCE-COMPUTER. IBM-PC.
         OBJECT-COMPUTER. IBM-PC.

        INPUT-OUTPUT SECTION.
         FILE-CONTROL.

           SELECT UNSORTED-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

           SELECT WORK-FILE ASSIGN TO SYSWORK.

           SELECT SORTED-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.

        FILE SECTION.


         FD UNSORTED-FILE
           VALUE OF FILE-ID IS "SORT.INP".
         01 IN-REC.
            05 IN-NAME PIC X(7).
            05 FILLER PIC XX.
            05 IN-AGE PIC 99.


         SD WORK-FILE.
         01 WORK-REC.
            05 FILLER PIC X(9).
            05 WORK-AGE PIC 99.

         FD SORTED-FILE
           VALUE OF FILE-ID IS "SORT.OUT".

         01 OUT-REC PIC X(80).


        WORKING-STORAGE SECTION.




       PROCEDURE DIVISION.

           SORT WORK-FILE
                ON DESCENDING KEY WORK-AGE
                USING UNSORTED-FILE
                GIVING SORTED-FILE.

           STOP RUN.

#--------------------------------------------------------------------------------#

                OUPUT FILE - SORT.OUT
            
#--------------------------------------------------------------------------------#


hemal    74
shashank 72
krish    44
khilan   42
nita     34
harshad  17
prem     15 
gediya   10
vd       06
amisha   01


  
Share: 


Didn't find what you were looking for? Find more on Program describes sorting technique Or get search suggestion and latest updates.

Courtney Hughes
Courtney Hughes author of Program describes sorting technique is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!