Operations on an array

Hello,
I made this loop on a 2-dim array:
float matrix1[27][27];
float N[27];
for (int i=0; i<27; i++){//loop on elements on a line
for (int j=0; j<27; j++){//loop elements on a column
matrix1[i][j] = hscatt->GetBinContent(i,j);
N[i] += matrix1[i][j];
}
}
so for every i, N[i] is the sum of the values of matrix1[27][27] in column i, with j running from 0 to 26.
[color=#FF0000]When it happens that the matrix1[i][j] values are zero over all the i-th column, the sum N[i] that comes out is not zero, but the program makes a mistake calculating absurd numbers like -4.0909e-499 or similar…[/color]
Why this? How can I do to have a zero from a simple sum of all zeros?
Maybe, is there some error related to the variables’ type or the fact of passing from a 2-dim to a 1-dim
array with the sum? But when the column elements are not all 0 the sum is computed correctly…
Thank you very much!
Elena

Hi,

you never initialize float N[27]; It starts with a random value, and you just add to it. Declaring it as

will repair it.

Cheers, Axel.