Still not getting the correct output of code taught

for input-> 1 2 3 4 5 -1
I am getting output-> 1 1 2 3 4 5

code link- https://ide.codingblocks.com/s/207093

I have edited your code… Try to submit now…