How do i use loops to find the some of numbers taking from an external file.

I already have the numbers listed on the screen, but i can't figure out how to show the sum of the numbers after the list.

Please help

Printable View

- 05-08-2002robjulesloops for sums
How do i use loops to find the some of numbers taking from an external file.

I already have the numbers listed on the screen, but i can't figure out how to show the sum of the numbers after the list.

Please help - 05-09-2002Shiro
You have the numbers listed on the screen. So you know how to read them from the file. The only thing you need to do is after each time you've read a number, update a sum-variable. Such like this:

Code:`sum = 0`

while not end of file

number = read number ()

sum = sum + number