COBOL
Program to Implement OCCURS Clause.
PROGRAM:
IDENTIFICATION DIVISION.
PROGRAM-ID OCC.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 I PIC 9(2).
01 TAB.
02 STUD OCCURS 3 TIMES.
03 SNO PIC 9(3).
03 SNAME PIC X(10).
03 M1 PIC 9(3).
03 M2 PIC 9(3).
03 M3 PIC 9(3).
03 TOTAL PIC 9(6).
PROCEDURE DIVISION.
PARA1.
PERFORM READ-PARA VARYING I FROM 1
BY 1 UNTIL I > 3
PERFORM DISP-PARA VARYING I FROM 1
BY 1 UNTIL I > 3.
STOP RUN.
READ-PARA.
DISPLAY "ENTER STUDENT
DETAILS".
DISPLAY " ENTER STUDENT
SNO,SNAME,MARKS1,MARKS2,MARKS3:", I.
ACCEPT SNO(I).
ACCEPT SNAME(I).
ACCEPT M1(I).
ACCEPT M2(I).
ACCEPT M3(I).
DISP-PARA.
DISPLAY "DETAILS ARE", I.
COMPUTE TOTAL(I) = M1(I) + M2(I) +
M3(I).
DISPLAY "SNO:", SNO(I).
DISPLAY "SNAME:",
SNAME(I).
DISPLAY "M1:", M1(I).
DISPLAY "M2:", M2(I).
DISPLAY "M3:", M3(I).
DISPLAY "TOTAL:",
TOTAL(I).
No comments:
Post a Comment