Quote:
Is that solution working properly according to question?
As programmer, part of your job is to ensure that your code meet requirements and is working properly.
It is a skill you must acquire as soon as possible, it is mandatory to any serious programmer.
To know if code is working properly, about the only solution is testing the different situation your code will encounter and check is answer is correct or not.
Unit testing - Wikipedia[
^]
When something go wrong, the debugger is the tool of choice to help you hunting bugs.
When you don't understand what your code is doing or why it does what it does, the answer is
debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.
Debugger - Wikipedia, the free encyclopedia[
^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.