
-----------------------------------
strugglin-angel
Mon Feb 07, 2005 11:05 pm

how do i find the sum of all numbers ?
-----------------------------------
how do i write a program that will find the sum of all numbers until an EOF of -99 is entered?

-----------------------------------
bugzpodder
Mon Feb 07, 2005 11:12 pm


-----------------------------------
this is best done using a 'loop' loop.  have an 'exit when' condition when EOF -99 occurs

-----------------------------------
strugglin-angel
Mon Feb 07, 2005 11:22 pm


-----------------------------------
oooo :D i thot it had to b done with arrayz...~_~" thank you ! ^_^

-----------------------------------
bugzpodder
Tue Feb 08, 2005 11:13 am


-----------------------------------
right, you dont really need an array.  the only thing you need to keep track of is the sum.

-----------------------------------
Viper
Tue Feb 08, 2005 1:02 pm


-----------------------------------
ull need the sum and the number of inputs not including the -99
eg 

loop
put "enter num"
get num
exit if num=-99
sum:=sum+num
numcount:=numcount+num
end loop

-----------------------------------
Delos
Tue Feb 08, 2005 3:14 pm


-----------------------------------
Viper, you've been around long enough to know 2 things:

1)
Use 
sum += num

Keeping in mind that 'sum' has to be initialized at its onset.

-----------------------------------
bugzpodder
Tue Feb 08, 2005 5:55 pm


-----------------------------------
okay, i know i havent used turing in a while, but shouldnt it be: 
exit when ...

-----------------------------------
Cervantes
Tue Feb 08, 2005 5:59 pm


-----------------------------------
That's correct.  It's not exit if

-----------------------------------
TheZsterBunny
Tue Feb 08, 2005 8:16 pm


-----------------------------------
...

arrays?

...

this program you're writing should be way before you need to worry about arrays.

good luck anyways.

-Z

-----------------------------------
strugglin-angel
Tue Feb 08, 2005 10:58 pm


-----------------------------------
lol thanx guyz y'all have been very helpful ^_^ ....and for arrays...lol i don't even noe wa dey are wa was i thinkin ~_~" lol i'm so nub =p

-----------------------------------
Martin
Tue Feb 08, 2005 11:40 pm


-----------------------------------
Just think about it as if you were doing the problem yourself.

"I'm going to give you an indeterminate number of numbers, and I need you to tell me the sum."

The best way to do this would simply be to keep a running total.

-----------------------------------
strugglin-angel
Wed Feb 09, 2005 12:00 am


-----------------------------------
:idea: hmm dats a very logical way of thinkin of it   :D hmm u guyz are soo gud at this .. i just mite pass comp sci this semester ^_^
