next up previous
Next: Display Up: Sample Programs Previous: If-then-Else

Do-Loop

      program loops

      implicit none
      integer i, num_intervals
      real PI, TwoPi
      real x, y
      Parameter(PI=3.141592653)

      do 10 i = 1,10
      write(*,*) i
   10 continue

      do i = 1, 10
      write(*,*) i
      end do

      open(1,file='data',type='unknown')
      write(*,100)
      read(*,*) num_intervals

      TwoPi = 2 * Pi
      do i = 1,num_intervals
         X = TwoPi / num_intervals * i
         Y = sin(x)
         write(1,110) x,y
      end do

  100 format('Please input the number of intervals: ',$)
  110 format(F10.2,F9.3)
      end



Russ Miller
Thu Sep 14 13:56:19 EDT 1995