Tuesday, October 13, 2009

book to be boaoak

#include
#include
#include
/*Write a Program to insert a particular character in a string
* after one specific character like
Str1 [] ="book"
Then in the above given string after character
'o' it should append a character 'a’, so output will be
Boaoak*/

int main()
{
char str1[100]="book";
char str2[100];
int i=0,j=0;

while(str1[i]!='\0')
{
if(str1[i]=='o')
{
str2[j]=str1[i];
j++;
str2[j]='a';
j++;i++;

}else
{
str2[j]=str1[i];
j++;i++;

}

}str2[j]='\0';
printf("replaced string is :%s",str2);
getch();
return 0;
}

No comments:

Post a Comment