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

Given an array A[n+m] of n+m numbers, where A[1] ... A[n] is sorted and A[n+1] ... A[n+m] is sorted. Design a linear time algorithm to obtain A[1...n+m] sorted using only O(1) extra space. Time Complexity of your algorithm should be O(n) and Space Complexity O(1).

0 Answers  


What is the difference between a function and a method in c?

0 Answers  


Write an interactive c program that will encode or decode a line of text. To encode a line of text, proceed as follows: Convert each character, including blank spaces, to its ASCII equivalent. Generate a positive random integer. Add this integer to the ASCII equivalent of each character. The same random integer will be used for the entire line of text. Suppose that N1 represents the lowest permissible value in the ASCII code, and N2 represents the highest permissible value. If the number obtained in step 2 above exceeds N2, then subtract the largest possible multiple of N2 from this number, and add the remainder to N1. Hence the encoded number will always fall between N1 and N2, and will therefore always represent some ASCII character. Display the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text. Be certain, however, that the same random number is used in decoding as was used in encoding.

1 Answers   Amazon, CSJM, HCL, Microsoft, TCS, Wipro,


helllo sir , what is the main use of the pointer ,array ,and the structure with the example of a programe

2 Answers  


what is the output of the following program? main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

7 Answers  






WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..

0 Answers  


How can you call a function, given its name as a string?

0 Answers  


What is a sequential access file?

0 Answers  


How are portions of a program disabled in demo versions?

0 Answers  


What is c standard library?

0 Answers  


What is difference between stdio h and conio h?

0 Answers  


Process by which one bit pattern in to another by bit wise operation is?

0 Answers   InterGraph,


Categories