4] SOFTWARE 47
DO 5 J=1, N
READ( *, 3 ) ID, ( X(K), K=1, M )
3 FORMAT( I5, 25F3.0/ (5X, 25F3.0) )
SUM = 0.0
DO 4 K=1, M
4 SUM = SUM + X(K)
AV = SUM / EM
5 WRITE( *, 6 ) J, ID, AV
6 FORMAT( I6, 3X, 'SUBJECT ', I6, 3X, 'AV= ', F9.2 )
STOP
END
Example input cards:
5 5
821 3 7 9 4 7
812 1 4 3 3 2
813 3 2 3 1 1
824 7 9 9 9 9
825 6 9 8 8 5
This program starts by reserving an array of 1000 elements for real numbers. Then it reads the first line of
input to get values for N and M, the number of students and the number of scores for each student. Then it writes
a message summarizing the task ahead.
The main loop starts next at the keyword DO. The loop starts there and ends at the statement numbered 5.
The work of the loop begins with reading another line of input, which the program expects to consist of a student
identifier and five test scores. Inside the main loop, there is a smaller loop that starts at the next DO and
continues just to the following line, numbered 4. The inner loop sums all the scores for that line of input. The
last work of the main loop is to divide the sum of test scores for the student by the number of tests in order to
compute an average score for that student. After writing the result for that student, the loop resumes with the next
student, until the scores for all the students have been averaged.
Pages:
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138