how can i sum all values that i got from a loop????
how can i sum all values that i got from a loop????
Last edited by alperen1994; 03-16-2009 at 11:47 AM.
What loop?
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
How are the values stored? Are they in an array? If so, just write another loop that traverses the array and keeps a running total.
If you got the values in a loop you can either write another loop as sean suggest or just put your "sum" code in the loop where you first process the values. You need to initialize some variable that is going to hold the sum to zero and then in the loop you add the values you want to sum up to this variable to get your running total.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens