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>



plssssss help !!....using array.. turbo c.. create a program that will accept number of words t..

Answer / 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

More C Interview Questions

why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

0 Answers  


Explain the bubble sort algorithm.

0 Answers  


how to swap 2 numbers in a single statement?

3 Answers  


what defference between c and c++ ?

6 Answers  


Write a program to implement queue.

0 Answers   Aricent,






What is the use of header files?

0 Answers  


What does %2f mean in c?

0 Answers  


please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................

0 Answers  


What is masking?

0 Answers  


What are keywords c?

0 Answers  


How to print "I Love My India" without using semi colon?

4 Answers  


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

2 Answers   Cap Gemini, HCL,


Categories