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
Differentiate call by value and call by reference?
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
What is a list in c?
Explain do array subscripts always start with zero?
Explain null pointer.
What is the difference between typedef and #define?
What are the types of data structures in c?
What is the argument of a function in c?
Write a program to reverse a linked list in c.
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
Why does notstrcat(string, "!");Work?
write a proram to reverse the string using switch case?
How can I sort a linked list?
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory
How are Structure passing and returning implemented by the complier?