Unable to remove the comma

Hi, sir, I am able to generate the strings but getting the wrong answer because of comma-separated strings, help me to remove the last comma, I am using “\b” it is working on devc++ but not working in the online compiler

please share ur code by pasting in cb ide

added suitable comments where the updates are made