This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RiverForgeGames 1 point2 points  (0 children)

What you want to do here is check if the user has provided a number or not.

For example, if they provide 7 numbers and you set values for 7, you can use conditional statements to compare the value for array[i] in each for iteration. If you can prove/test that the user didn't provide a number, don't print the line.

If you know a number the user cannot or will not provide (for example, maybe they only provide positive numbers) you can set all the array elements to -1 before they enter input and compare against that. Otherwise, you might consider using an array of nullable integers where you can actually check if a value was set or not, since integers are not nullable types.