I ran the code and had no output but normal termination (returned 0)
There is a logic problem in your code though, time to break out the debugger :+) I reckon I know what the problem is, but if you learn how to use a debugger you will discover it yourself, and learn how massively important the debugger is.
Hopefully your IDE has a GUI debugger in it. You should be able to set break points, a watch-list of variables and their values. Step through the code 1 line at a time, keep an eye on the values and deduce where it all goes wrong.
If you r IDE does not have a debugger in it, or you code with an editor only, then there are command line versions such gdb.