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


Please Help Members By Posting Answers For Below Questions

Differentiate call by value and call by reference?

571


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

2539


What is a list in c?

624


Explain do array subscripts always start with zero?

763


Explain null pointer.

625






What is the difference between typedef and #define?

552


What are the types of data structures in c?

606


What is the argument of a function in c?

579


Write a program to reverse a linked list in c.

649


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.

1574


Why does notstrcat(string, "!");Work?

646


write a proram to reverse the string using switch case?

2473


How can I sort a linked list?

639


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

736


How are Structure passing and returning implemented by the complier?

717