How were the earth, sun and moon formed?
Answer / Parit Agarwal
Here's a simple example of an RPG program that calculates and displays the marks of five students in three subjects:
01 PROC PGM
02 DCL VAR(STUDENT_REC) TYPE(A) DIMENSION(5)
03 DCL VAR(SUBJECT_CODE) CHAR(3) VALUE('ENG')
04 DCL VAR(MARKS(15)) SSIZE(15)
05 DCL VAR(TOTAL_ENG) SSIZE(8) Zeros
06 DCL VAR(AVG_ENG) SSIZE(8) Zeros
07
08 PERFORM calculation-eng FOR E FROM 1 THRU 5
09
10 PROCEDURE calculation-eng
11 ADDRESS STUDENT_REC(E)
12 SETVAL SUBJECT_CODE TO 'ENG'
13
14 PERFORM GET-MARKS FOR A FROM 1 THRU 3
15
16 PROCEDURE GET-MARKS
17 ADDRESS STUDENT_REC(A)
18 SETVAL MARKS(A) TO INPUT('Enter mark for subject ' SUBJECT_CODE : A:1 CHAR FORMAT(9.2))
19 IF (SUBSTR(SUBJECT_CODE, 2, 1) = '2') THEN
20 ADD TOTAL_ENG(A) TO MARKS(A)
21 ENDIF
22
23 ENDPROC GET-MARKS
24
25 PERFORM calculation-math FOR E FROM 1 THRU 5 AFTER CALCULATION-ENG
26
27 PROCEDURE calculation-math
28 ADDRESS STUDENT_REC(E)
29 SETVAL SUBJECT_CODE TO 'MATH'
30
31 PERFORM GET-MARKS FOR A FROM 1 THRU 3
32
33 ENDPROC CALCULATION-MATH
34
35 PERFORM calculation-sci FOR E FROM 1 THRU 5 AFTER CALCULATION-MATH
36
37 PROCEDURE calculation-sci
38 ADDRESS STUDENT_REC(E)
39 SETVAL SUBJECT_CODE TO 'SCI'
40
41 PERFORM GET-MARKS FOR A FROM 1 THRU 3
42
43 ENDPROC CALCULATION-SCI
44
45 IF (SUBSTR(SUBJECT_CODE, 2, 1) = 'E') THEN
46 ADD TOTAL_ENG(E) TO AVG_ENG
47 ENDIF
48
49 DISPLAY 'Student A' : SUBSTR(STUDENT_REC(1), 2, 15) : 'English: ' MARKS(1) : 'Math: ' MARKS(2) : 'Science: ' MARKS(3) :
50
51 IF (SUBSTR(STUDENT_REC(1), 2, 15) = 'Student E') THEN
52 DISPLAY 'Total English for student E: ' AVG_ENG :
53 DISPLAY 'Average for students: ' ((AVG_ENG DIV 5) FORMAT(9.2))
54 ENDIF
55
56 ENDPROC PGM
| Is This Answer Correct ? | 0 Yes | 0 No |
How many moons do mars have?
What is the speed of solar wind?
How stars are formed?
How is saturn like earth?
Does non-carbon based life exist somewhere in the universe?
How many moons does uranus have?
Explain how fast is the solar wind?
Explain is pluto really a planet?
Tell me how long is it until our solar system ceases to exist?
What are the super giant novae stars?
Tell me how many planets are in the new solar system?
How many moons do Mars planet have?