When i take input as string why its not giving op but on char array it's giving

Can u please tell tell me the difference https://ide.codingblocks.com/s/102318

It is because, you are taking output string, and also passing i and j as pointers, strings work in similar manner, but for that you are not required to pass the i and j as parameters, in that case, we will work entirely on string, rather than considering values of i and j.