Move all X at the end


Y is it not printing any result??
I know the correct code !! so can you please tell me in this code…what is the mistake that there is no result printed… I want to know the error?? so that i can understand where am i going wrong with my concept …

Hey @apoorv.chauhann the logic you Implemented is not correct, when you are not getting x you are printing that character and move forward and when you get x you re also printing that. What you have to do is make all your x move in the end in an array and then printing it :slight_smile:

yeah, but im priting those character( if im not getting x) and then im putting a recurssive call…so that it skips all the ‘x’ charcter and then while returning back it prints all the x… So wont this code first print all the character which is not x and then print x???

No my friend , that’s not how recursion works. You have to change your implementation

https://ide.codingblocks.com/s/348148...its running …i was not getting an output because there was a semicolon in if(i<=l) statement (by mistake)…i dint change any logic …so is this a luck and actually im implementing a wrong logic or my logic is correct???

I can’t see any line in the code you have provided to me earlier. Moreover this new code you have shared only has cout hello world. Maybe you forgot to save it.