!     Last change:  X     5 Oct 2004    3:14 pm
PROGRAM Mean_of_a_list_lab5_example1
!
! Use a 1-D compile-time array and function call
!
IMPLICIT NONE
INTEGER :: i
INTEGER, PARAMETER :: NumGrades = 10
REAL, DIMENSION(NumGrades) :: Grades

WRITE (*,*) "Enter the", NumGrades, " real numbers:"
READ (*,*) Grades

!output scores in two different ways
DO i=1, NumGrades
   WRITE(*,*) "Score ", i, " is ", Grades(i)
END DO
WRITE(*,*) "The scores are ", Grades

WRITE (*,*) "The mean of the ", NumGrades, " scores is ", Mean(Grades, NumGrades)

STOP
CONTAINS

!-Mean function defined below-----------------------------

FUNCTION Mean(X, NumElements)

   INTEGER, INTENT(IN) :: NumElements
   REAL, DIMENSION(NumElements), INTENT(IN) :: X
   REAL :: Mean

   Mean = SUM(X)/ REAL(NumElements)

RETURN
END FUNCTION Mean

END PROGRAM Mean_of_a_list_lab5_example1

