Input: The first line contains the primary string (PS) The next line contains a character (c) The next line contains a string (s) Output: Print the string PS with every occurence of c replaced by s.
#include<stdio.h>
#include<string.h>
int main()
{
char PS[1000],s[1000],ch;
scanf("%s %c %s", PS,&ch,s);
for(int i=0;i<strlen(PS);i++)
{
if(PS[i]==ch)
{
for(int i=0;i<strlen(s);i++)
printf("%c",s[i]);
}
else
printf("%c",PS[i]);
}
return 0;
}
Thanks
Happy Computing!
No comments:
Post a Comment