M. Gumblert wrote:
Check line 7 what your comment says and what actual code does. It increases numOfDel irrespective whether body of
if statement has been entered.
I've never wrote such comments myself to explain what code is doing. I'd suggest you don't write them too. The main reason of mine was: they just clutter the code and prevents you from concentrating on actual code. Some of the comments are useful, however, they aren't present in this code. Useful comments are similar to
"// changing value to 1 because it is an idle state". This comment also would be redundant going further, but that should give you an idea, what the comment should explain - WHY you are doing so, not WHAT you are doing.
Comments supposed to explain things which aren't obvious from the code. Don't confuse obvious and readable. While your code statements are obvious, some of them aren't readable in a program's context. The main reason of that are - again comments. Instead of explaining things in comments, try to explain them in a code.
For example:
Bad
Better
Also, you tend to write comments in the subsequent line explaining what the past statement does. Much better is to write comment first, and then the corresponding code construct (once again, much better is not to write such comments at all).
In the example above, you have variable
numOfDel, however, comment down below says, the number of userinputs. Do you see how code and the comments are out of sync in your source code? It is much more dangerous to have misleading comment than not to have it. However, in this case is good as it revealed where you need to improve.
Give a try renaming your variables appropriately and removing all the comments so we could see whether you understand what the variables represent (or meant to represent), that way I think we could help you better to go back on the track.