PROGRAM avg1

IMPLICIT NONE

! A program to average an arbitrarily long list of numbers.

! This version used std in / std out for i/o

INTEGER :: i, n
REAL :: x, avg

avg = 0

WRITE(*,*)'enter number of numbers to average'
READ(*,*)n

DO i = 1,n
   WRITE(*,*) 'enter a number to average'
   READ(*,*) x
   avg = avg + x
ENDDO

WRITE(*,*)'the average is : ',avg / n

END PROGRAM avg1
