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 |
Tell me how many moons does neptune have?
When did solar system come into existence? What is the expected life of solar system?
How big is the universe?
What is the part of the sun that we can see without any instruments?
Explain how old is our earth?
A solar eclipse can only occur at?
Of the three types of meteorites, which is the most common, in terms of the number of samples, to fall to earth in recorded history?
Which is the first unmanned space vehicle which landed on the moon?
The celestial coordinate analogous to latitude is called?
The persied meteor showers are viewed in the state of maine during what month?
Does time stop at an event horizon?
Mars has a thin atmosphere composed mainly of what gas?