home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchk294s.zip / ftnchek-2.9.4 / correct.f < prev    next >
Text File  |  1996-02-18  |  1KB  |  48 lines

  1. C       AUTHORS: MIKE MYERS AND LUCIA SPAGNUOLO
  2. C       DATE:    MAY 8, 1989
  3. C
  4. C       Variables:
  5. C               SCORE -> an array of test scores
  6. C               SUM ->   sum of the test scores
  7. C               COUNT -> counter of scores read in
  8. C               I ->     loop counter
  9. C
  10.        REAL FUNCTION COMPAV(SCORE,COUNT)
  11.             INTEGER SUM,COUNT,I,SCORE(5)
  12. C
  13.             SUM = 0
  14.             DO 30 I = 1,COUNT
  15.                 SUM = SUM + SCORE(I)
  16. 30          CONTINUE
  17.             COMPAV = FLOAT(SUM)/FLOAT(COUNT)
  18.         END
  19. C
  20. C
  21.         PROGRAM AVENUM
  22. C
  23. C                       MAIN PROGRAM
  24. C
  25. C       AUTHOR:   LOIS BIGBIE
  26. C       DATE:     MAY 15, 1990
  27. C
  28. C       Variables:
  29. C               MAXNOS -> maximum number of input values
  30. C               NUMS    -> an array of numbers
  31. C               COUNT   -> exact number of input values
  32. C               AVG     -> average returned by COMPAV
  33. C               I       -> loop counter
  34. C
  35. C
  36.             INTEGER MAXNOS
  37.             PARAMETER(MAXNOS=5)
  38.             INTEGER I, NUMS(MAXNOS), COUNT
  39.             REAL AVG,COMPAV
  40.             COUNT = 0
  41.             DO 80 I = 1,MAXNOS
  42.                 READ (5,*,END=100) NUMS(I)
  43.                 COUNT = COUNT + 1
  44. 80          CONTINUE
  45. 100         AVG = COMPAV(NUMS, COUNT)
  46.             WRITE(6,*) 'AVERAGE =',AVG
  47.         END
  48.