Not giving any output
The approach you are trying to follow in your code is wrong… You can use recursion as follows :
void replacepi(string str,string osf)
{
if(str.length()==0)
{
cout<<osf;
return;
}
if(str.length()==1)
{
cout<<osf+str[0];
return;
}
if(str[0]==‘p’ && str[1]==‘i’)
{
replacepi(str.substr(2),osf+“3.14”);
}
else
{
replacepi(str.substr(1),osf+str[0]);
}
}
please help me in this question
I have already shared the approach you can follow up in your question… Pls use that only…