[Solved] Error at end of rainfall program [closed]


A possible culprit is your loop condition in displayOutput(). Here’s the line:

for (int i = 0; rainArray[i] <= NUM_MONTHS; i++)

It’s presumably supposed to loop through every element in rainArray. However, currently it will loop through an arbitrary number of times depending on your input data. It’s entirely possible that it’s going past the end of your array and trying to access memory that it’s not supposed to access.

That may explain the error message you saw. It’s hard to tell for sure without knowing what input data you’re testing with though.

Try changing the loop to this:

for (int i = 0; i < NUM_MONTHS; i++)

3

solved Error at end of rainfall program [closed]