A lot of times we see simple logic based questions, like this one. They are generally posted by people very new to programming, and do not know some very basic concepts (arrays, pointers, loops etc). I am sometimes tempted to comment that they should first follow a tutorial or book, but it would be rude(?).
- They are (probably) not duplicates, on-topic, and the OP has done some effort in it.
- They have provided explanation of the code and both are clear.
- They are just missing a little detail or doing something (small) subtly wrong.
How should we deal with this?
I see that they are often downvoted, but in here, the top voted answer is perfectly against this one.
On one hand, the question is unlikely to be helpful to many other people because it is so small and specific. Also, it can be argued that they could have found the error by using a debugger, or just going through the code better (Rubber Duck). It can also be said that if they had gone through online resources and documentation, they would have solved it.
On the other hand, again, they have written the code, they (may) have researched it, but either did not know how to look, or where to look (They are new to programming). They do not have enough experience of "googling the error" and trying out possible solutions or linking that problem to their own. They do not know many common problems and how to avoid them.
But again, the point is that we cannot be sure if they have tried to solve their problem.
They might just be lazy! I say this because I rarely see references in these posts.
I was reading up on the many questions and the long discussions when this question was closed. I actually wanted to post this as an answer, but here goes:
Even after reading all the material and discussion, I am confused.
I still do not understand why this question is bad. It has currently been closed as off-topic.
Let's go over it from the Help Center:
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. See: How to create a Minimal, Reproducible Example.
- Desired Behaviour: Sure. We need to add those numbers with every digit > 5.
6978, 9, 66, 89, 76, 96
are all valid and are to be added.
6907, 681, 199, 959, 5
are all invalid and are to be skipped.
- A Specific Problem: The problem is that they are getting the wrong output.
- Shortest code which Reproduces the Error: I believe so. It is 40 lines long, but mostly due to bad formatting. The code is still short and clear (IMO). And it reproduces the error.
Note that I am specifically using the top post as the reference.
Please forgive me if I am being thick, but I feel this is a very borderline case. As long as I don't understand the tipping point, I (and possibly others) cannot meaningfully contribute to this site.
And please, no meta effect!