how can i sum all values that i got from a loop????
This is a discussion on summing all values up within the C Programming forums, part of the General Programming Boards category; 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.
I used to be an adventurer like you... then I took an arrow to the knee.