home *** CD-ROM | disk | FTP | other *** search
/ Grolier Multimedia Encyclopedia 1995 / GME95.iso / z40 / 1103601b.gif < prev    next >
Graphics Interchange Format  |  1994-08-24  |  6KB  |  454x290  |  4-bit (3 colors)
Labels: text | screenshot | font | black and white | white | number
OCR: 1 C PROGRAM TO AVERAGE A LIST OF NUMBERS 2 C INPUT-NUMBER OF VALUES TO BE AVERAGED 3 C LIST OF VALUES 4 C OUTPUT-AVERAGE OF INPUT 5 INTEGER COUNT , SUM, AVE, X, I 6 READ (5,1) COUNT 7 1 FORMAT (15) 8 SUM = 0 9 DO 2 1 = 1, COUNT 10 READ (5,1) X 11 SUM = SUM + X 12 2 CONTINUE 13 AVE = SUM/COUNT 14 WRITE (6,3) AVE 15 3 FORMAT ( "THE AVERAGE IS"), 15 16 END Lines 1-4 are comments that describe what the program is intended to do. Lines 5-6 read the first data value-the size of the list to be averaged. Lines 7-9 set the initial conditions for the calculations that follow. Lines 10-11 are repeated once for each data value, and a running sum of the values is accumulated in the variable sum. Finally, the average is computed (line 13) and printed (lines 14-15).