Https://ide.codingblocks.com/s/42834

https://ide.codingblocks.com/s/42834
Reverse stack using recursion …
it is printing upto 5 digit only;
i think the problem is with printing loop
and it shows the size to be 9 also…but loops runs 5 times only and if we replace s1.size() by 9 then it prints all the elements…i don’t know why is this happenning
Thanks…

You have made a mistake while printing the elements.You need to print the elements while the stack is not empty ,you have used for loop,and your loop condition is till stack.size(),which is changing as your popping the elements.
Made the changes in ur code:
https://ide.codingblocks.com/s/42836