ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
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>
 Question Submitted By :: Hmmm
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
#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 ?    2 Yes 0 No
Swapnil Chhajer
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what is the diff between the printf and sprintf functions?? and what is the syntax for this two functions ??  4
# define prod(a,b)=a*b main() { int x=2; int y=3; printf("%d",prod(x+2,y-10)); } the output of the program is a.8 b.6 c.7 d.none TCS5
i want the code for printing the output as follows 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4  1
write the function int countchtr(char string[],int ch);which returns the number of timesthe character ch appears in the string. for example the call countchtr("she lives in Newyork",'e') would return 3.  4
main() { printf("hello%d",print("QUARK test?")); }  4
pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used. Persistent4
Can we include one C program into another C program if yes how? Infosys4
5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort Accenture2
write a program to print the all 4digits numbers & whose squares must me even numbers? Virtusa2
wap to print "hello world" without using the main function. TCS16
write a own function for strstr LG-Soft1
Determine if a number is a power of 2 at O(1).  1
Given a single Linked list with lakhs of nodes and length unknown how do you optimally delete the nth element from the list? Oracle1
what is the diference between pointer to the function and function to the pointer?  2
How the C program can be compiled? HP7
what is difference between ++(*p) and (*p)++ Accenture15
fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? } NDS13
what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1 IBM1
Given an unsigned integer, find if the number is power of 2?  4
wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain  3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com