Replace all pi prblem


is this correct

@vanisinghal0201 it is not correct because a character means a single character, two characters become a string. Therefore ‘14’ cannot be assigned as a character

hi @vanisinghal0201 you haven’t taken input for s in the main function. Secondly, this function is not generic because it is only checking for s[0] and s[1] but pi can be present later in the string as well. Your base case is also missing (how will the program terminate if length of s > 1 ?)

how do we apply base case in this

@vanisinghal0201 if index exceeds the length of the string - 1 or len-2 then also s[index] and s[index+1] cannot be accessed, so that can be your base case

hi @vanisinghal0201 this is the approach that I used https://ide.codingblocks.com/s/234223

https://ide.codingblocks.com/s/234264 this should also work

hi @vanisinghal0201 this function will give your segmentation fault because you are trying to access out of bounds element, do a dry run once and you’ll see.

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.