You put breakpoints at the points you get wrong results and then you debug it with the red arrow, you can open the debugging windows to check every value that your variables get in each step to understand and find where it goes wrong, so you can fix it
You must be referring to a specific debugger. Perhaps you should explain which program you're talking about.
What can this strange device be?
When I touch it, it gives forth a sound
It's got wires that vibrate and give music
What can this thing be that I found?