PROGRAM Reverse
   IMPLICIT NONE

   INTEGER, PARAMETER :: Size = 30
   INTEGER, DIMENSION(1:Size) :: a
   INTEGER           :: NumEle, Head, Tail, Temp, I

   WRITE(*,*) 'Number of elements, please --->'
   READ(*,*) NumEle
   WRITE(*,*) 'Enter The array:'
   READ(*,*) (a(I), I=1 , NumEle)

   WRITE(*,*) 'Here is what we have:'
   WRITE(*,*) (a(I), I=1 , NumEle)

   Head = 1
   Tail = NumEle

   DO 
      IF (Head >= Tail) EXIT
      Temp = a(Head)
      a(Head) = a(tail)
      a(Tail) = Temp
      Head = Head + 1
      Tail = Tail - 1
   END DO
   
   WRITE(*,*) 'Here is what we have now:'
   WRITE(*,*) (a(I), I=1 , NumEle)

END PROGRAM Reverse
