IDENTIFICATION DIVISION.
PROGRAM-ID. QUESTION2.
AUTHOR. GYAN AND CHANDRA.
ENVIRONMENT DIVISION.
WORKING- STORAGE SECTION.
01 STUDENT-RECORD
02 STUDENT OCCUR 5 TIMES.
03 ENR-NO PIC 9(9)
03 NAME PIC X (20).
03 COURSE PIC X(5)
01 DATA-FOR-SORTING
02 I PIC 9.
02 J PIC 9.
02 C PIC 9 VALUE 5.
02 TEMP-EN PIC 9(9).
02 TEMP-N PIC X(20).
02 TEMP-C PIC X(5)
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY “ INPUT STUDENT RECORDS”.
DISPLAY “ ---------------- “.
PERFORM PROCESS-PARA
VARYING I FORM 1 BY 1
UNTIL I>C.
PERFORM SORTING-PARA
VARING I FORM 1 BY 1
UNTIL I > C.
STOP RUN.
PROCESS-PARA.
DISPLAY “INPUT ENROLMENT NO.”
ACCEPT ENR-NO(I)
DISPLAY “INPUT COURSE NAME:”.
ACCEPT COURSE(I)
DISPLAY “INPUT STUDENT NAME:”
ACCEPT NAME (I)
SORTING-PARA.
PERFORM COMPARISION-PARA
VARYING J FROM 1 BY 1
UNTIL J>C.
COMPARISION-PARA.
IF NAME(I)
MOVE NAME(I) TO TEMP-N
MOVE NAME(J) TO NAME-(I)
MOVE TEMP-N TO NAME-(J)
MOVE ENR-NO(I) TO TEMP-EN
MOVE ENR-NO(J) TO ENR-NO(I)
MOVE TEMP-EN TO ENR-NO(J)
MOVE COURSE(I) TO TEMP-C
MOVE COURSE(J) TO COURSE(I)
MOVE TEMP-C TO COURSE(J)
PRINTING-PARA.
DISPLAY “ENROLMENT NO.:”
DISPLAY ENR-NO(I)
DISPLAY “STUDENT NAME.:’
DISPLAY NAME(I)
DISPLAY “COURSE NAME:”
DISPLAY COURSE (I).
No comments:
Post a Comment