root/branch/twedit/sum.f90

Revision 1262, 497 bytes (checked in by mswat, 2 years ago)
Line 
1! sum.f90
2! Performs summations using in a loop using EXIT statement
3! Saves inputted information and the summation in a data file
4
5program summation
6implicit none
7integer :: sum, a
8
9print*, "This program performs summations. Enter 0 to stop."
10open(unit=10, file="SumData.DAT")
11
12sum = 0
13
14do
15 print*, "Add:"
16 read*, a
17 if (a == 0) then
18  exit
19 else
20  sum = sum + a
21 end if
22 write(10,*) a
23end do
24
25print*, "Summation =", sum
26write(10,*) "Summation =", sum
27close(10)
28
29end
Note: See TracBrowser for help on using the browser.