! ! This program written by Clint Whaley for CS 1073. It is an optional ! programming exercise given on 9/29/09. ! PROGRAM sumloop ! ! This program prints out the sum of all integers between an initial starting ! value (BEG) and an ending value (END) inclusive. ! IMPLICIT NONE INTEGER :: i, beg, end, sum ! ! Get the beginning and end numbers, and an increment. The asg in class ! said use a constant increment of 3, but I decided to generalize ! PRINT *, 'Enter the number to begin summation at:' READ *, beg PRINT *, 'Enter the number to end summation at:' READ *, end ! ! Sum up all numbers [beg,end] ! sum = 0 DO i = beg, end sum = sum + i END DO PRINT *, 'Sum is:', sum END PROGRAM sumloop