Recursive program to insert a star between pair of identical characters | Recursive C # program to insert * between two consecutive same characters . ; Function to insert * at desired position ; Append current character ; If we reached last character ; If next character is same , append ' * ' ; Driver code
using System ; class GFG { static String output = " " ; static void pairStar ( String input , int i ) { output = output + input [ i ] ; if ( i == input . Length - 1 ) return ; if ( input [ i ] == input [ i + 1 ] ) output = output + ' * ' ; pairStar ( input , i + 1 ) ; } public static void Main ( String [ ] args ) { String input = " geeks " ; pairStar ( input , 0 ) ; Console . WriteLine ( output ) ; } }