PROGRAM FOR INPUT RECORDS INTO THE FILE USING EXTEND MODE.
IDENTIFICATION DIVISION. PROGRAM-ID. IP. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT OUT1 ASSIGN TO DISK ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD OUT1 LABEL RECORDS ARE STANDARD VALUE OF FILE-ID IS "REPORT.TXT". 01 STD-REC. 05 NO1 PIC 99. 05 FILLER PIC XX. 05 NAME1 PIC X(10). 05 FILLER PIC XX. 05 MARK1 PIC 999 OCCURS 5 TIMES. 05 FILLER PIC XXX. 05 TOTAL PIC 999. WORKING-STORAGE SECTION. 01 FLAG PIC X VALUE "Y". 01 DASH2 PIC X(70) VALUE ALL"=". 01 J PIC 9 VALUE 1. PROCEDURE DIVISION. PARA1. OPEN EXTEND OUT1. PERFORM PARA2 UNTIL FLAG="N". CLOSE OUT1. STOP RUN. PARA2. DISPLAY "ENTER ROLLNO:". ACCEPT NO1. DISPLAY "ENTER NAME:". ACCEPT NAME1. PERFORM VARYING J FROM 1 BY 1 UNTIL J>5 DISPLAY "ENTER MARK " J ":" ACCEPT MARK1(J) ADD MARK1(J) TO TOTAL. WRITE STD-REC. DISPLAY "DO U WANT TO ENTER AGAIN?(Y/N):". ACCEPT FLAG.