Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How were the earth, sun and moon formed?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you enjoy most being an Astronomer?

115


Why did you want to become an astronomer?

144