Please check the code what's error

please check it

you dont need to replace the character you can simply print 3.14 when you encounter pi. as doing this would include changing the original string which is not recommended and moving all the characters is an inefficient as well as more error prone process.
Code:

But the process I used is the process told by prateek bhaiya.

yes your logic is correct, i was just giving a general advice, anyway in your code you have made a silly mistake instead of a[i+3] = ‘4’ you have written a[i+4] = ‘4’