WP is correct, but I can't help but wonder what the logic is behind this program.
Correct me if I'm wrong:
You ask the user for the input of how many odd numbers they want printed out. That is stored in n
You initialize an array of the length n, but don't populate it with anything.
You then iterate through from 0 to the number of odd numbers requested, and sum up the odd numbers in the array. But since the array isn't populated, all values are initialized to 0.
Thus it's returning 0 as a sum, correct?
The reason I'm have a problem wrapping my head around it, is that the number array would need to handle any number of odd numbers requested, so storing them in memory could be troublesome.
The solution that I see is either:
1. Multiply the items requested by 2, then iterate 1 through the multiplied number and add the odd values.
2. Asking the user for the beginning number and ending number to sum up the negative values.
2. Using another method that "yield returns" the next odd number.
In any case there is no need for the array. The first two methods are better for beginner programmers.
But if you want to learn about the workings of yield, you can see a simple example in my blog: ( http://forum.codecal...le-using-yield/ )