Advertisement
iamcreasy

Ask for length, Accept numbers in new line, print them out

Jan 14th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ! Fortran Program
  2.  
  3. program TEST
  4.         implicit none
  5.  
  6.         ! Non executable Code
  7.  
  8.         integer :: i
  9.         integer :: arrayLength
  10.         real, dimension(:), allocatable :: array
  11.  
  12.         ! Executable Code
  13.  
  14.         ! Ask the length of array
  15.         print *, "Length of array :"
  16.         read *, arrayLength
  17.  
  18.         ! allocate the array
  19.         allocate(array(arrayLength))
  20.  
  21.         ! Accept list of numbers for Array
  22.         do i = 1, arrayLength
  23.                 read *, array(i)
  24.         end do
  25.  
  26.         ! Print all elements in Array
  27.         do i = 1, arrayLength
  28.                 print *, array(i)
  29.         end do
  30. end program TEST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement