How can i apply recursion here

https://hack.codingblocks.com/contests/c/512/71

i can think of only the while loop approach but this question was listed under recursion subtopic in the assignment

Yes this question can be simply done by iteration ie using for or while loop.

To apply recursion you can pass the string and the index in recursive function, and check in base case when index is equal to size of string