plssssss help !!....using array.. turbo c..
create a program that will accept number of words to be
consored.
.a word must not exceed 10 characters long
.the text to be entered will be no longer than 200 characters
.there will be no 10 words
example:
enter number of words to be censor: 5
enter words to censor:
windows
office
microsoft
bill
gates
enter text to censor:
bill gates founded microsoft and makes office and windows
sample output:
<consored> <censored> founded <censored> and makes
<censored> and <censored>
Answer Posted / swapnil chhajer
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int nocw,i,j,flag=0;
char
cenWords[20][12],text[205],temp[12],finalText[450]={'\0'};
printf("Enter number of words to be censor : ");
scanf("%d",&nocw);
printf("\nEnter words to be censor : ");
for(i=0;i<nocw;i++)
scanf("%s",cenWords[i]);
fflush(stdin);
printf("\nEnter text to censor : ");
gets(text);
for(i=0;i<strlen(text);i++)
{
j=0;
flag=0;
while(!(text[i]==' '||text[i]=='\t'||text[i]=='\n'))
{
temp[j++]=text[i++];
}
temp[j]='\0';
for(j=0;j<nocw;j++)
{
if(strcmp(temp,cenWords[j])==0)
{
strcat(finalText,"<censored> ");
flag=1;
break;
}
}
if(flag==0)
{
strcat(finalText,temp);
strcat(finalText," ");
}
}
printf("\n\n :: FINAL TEXT :: \n\n");
puts(finalText);
getchar();
return 0;
}
| Is This Answer Correct ? | 6 Yes | 4 No |
Post New Answer View All Answers
Write a program for finding factorial of a number.
Explain the properties of union.
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
What are the differences between Structures and Arrays?
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
What is define directive?
What does %2f mean in c?
program to convert a integer to string in c language'
What is cohesion in c?
What do you mean by invalid pointer arithmetic?
How to delete a node from linked list w/o using collectons?
Explain what standard functions are available to manipulate strings?
What are variables and it what way is it different from constants?
What is the use of function overloading in C?