#include<stdio.h>
main()
{
char line[80],ar[5],newline[80];
int i=0,j=0,k=0,count=0;
printf("Enter a sentence:\n");
gets(line);
while(line[i]!='\0')
{
if((line[i]=='t' || line[i]=='T'))
{
for(j=0;j<3;j++)
{
ar[j]=line[i];
newline[k]=line[i];
k++;
i++;
}
ar[j]='\0';
strupr(ar);
if(strcmp(ar,"THE")==0)
{
count++;
k-=3;
}
}
else
{
newline[k]=line[i];
i++;
k++;
}
}
newline[k]='\0';
printf("\nThe is occured %d times",count);
printf("\nThe modified line is : \n%s",newline);
}
OUTPUT
Enter a sentence:
this is the program to remove the words THE from the sentence
The is occured 4 times
The modified line is :
this is program to remove words from sentence