After initializing, the random values are no longer, but all values for X are zero
Also, if I change the upper limit for the loop, line starting with X[i] produces error "Array subscript out of range".
If I comment out the X[i] line, The line starting with "Y = " works fine.
As always: post ENTIRE formula. Really. We can’t help you unless we can copy-paste the code on OUR end and check what is wrong with the ENTIRE formula. Your problem is apparently OUTSIDE the small snippets that you post.
The mistake you are making is semicolon right after for() statement.
You’ve got this:
for( i = 1; i < BarCount; i++ ) ; // THIS semicolon is the entire body of for loop
// subsequent block is executed AFTER for loop
// so 'i' variable is equal BarCount (one too much)
{
...
}
You should have for loop written the way I WROTE in original reply.
X = 0; // init
for( i = 0; i < BarCount; i++ )
{
....
}