I am not able to look at the code image in detail right now (will later), but my initial suggestion for debugging, if you are not familiar with break points, is to add a few
cout statements inside each
else blocks identifying where you are, and also displaying the current value of the variables. This will probably help you.
…back to the breakpoints. You can place breakpoints at each of the
else statements and their closing braces. If you look at the “locals” section on the lower left hand side pane of Visual Studio you can see the value of each variable at that particular break point.
Let me know if any of that helps.