Tiberius Marius wrote:I compiled it with pen and paper as i m not very familiar with IDEs .
Well done, it's really good practice to 'execute' the code on pen and paper it's a great way of finding bugs when you haven't got an
IDE and for some problems can even be easier than stepping through the code in an IDE.
And congratulations on finding and solving the problem yourself.
Finally thank you for posting the solution.