sum on loop

I have an struct array (5 elements) with 3 ints, i connect that array with a for each loop. At the end of the loop I set a variable with a format text to give me the three ints. The question is, how can I get the result of the sum of the 5 elements of each int? Now I just get the ints of the last element, i dont know how to keep the int on the first loop and keep adding each int to sum all.

Put all this code into a function so you can make use of local vars.

In the loop you’ll set a tracking var for the ints you want to save. You can use the loops index as a condition.

See, that’s why I deleted my post. As OP later says:

Each int? Do they have an int 23561 that should add up to 17?!

Sounds to me that he wants access to the ints and sums.

Index0 sum
Index1 sum
Index2 sum

then sum +sum +sum

¯_(ツ)_/¯

image

Pure Functions

Further thought…Simplify

Yeah the thing is each int has to be added independtly, I mean the first int with all the array elements of the first int and so on, like if you wanted to add on a game all the kills, deaths and money from a team taking all the players

I thought it was an easier way to sum each element on array like for example when in C++ you do a += at the end of the array

So you want sum of int1, sum of int2 etc?

Yeah I found a solution similar to that. Thanks a lot!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.