Could please have a look at my code and tell me what i am doing wrong? why is it reading 0.14 as 4?
Replace all pi challenge
You are storing ‘0.14’ as a single character in str[i+1] but they are actually 4 different characters. So it is overwritten from 0 to . to 1 to 4 and only 4 is stored. Separate these as:-
str[i] = '3';
str[i+1]='.';
str[i+2]='1';
str[i+3]='4';
Hey, this way its overwriting the other characters. If the input is xpixpi then the output should be x3.14x3.14
In your code length of string would be constant i.e 7 for (xpippix) and hence on first replacement, it would become x3.14ix i.e. pip will be occupied by .14 think how you can handle this case? Hint: shift the characters by 2 to the right, then even if they are replaced it would have no effect on the string, i.e. your string length starts with 7 then increase to 9, then to 11
(Why the increment of 2 characters and not 4?
because pi is of 2 characters overwritten by 3. and 2 character length for 14 is required.)
Dry Run: -
xpippix -> xpipippix (after shift of two characters)
xpipippix -> x3.14ppix (Replacement for pi)
and this will continue through recursion
I have modified your code:
Thankyou for your help 
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.