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
What is the advantage of using #define to declare a constant?
What is #include cctype?
Explain what math functions are available for integers? For floating point?
Is it valid to address one element beyond the end of an array?
What is the purpose of sprintf?
What is identifiers in c with examples?
What are data types in c language?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
Why is c known as a mother language?
Who invented b language?
What is the function of multilevel pointer in c?
Why is a semicolon (;) put at the end of every program statement?
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.