Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

1. Write a C program to count the number of occurrence
of
a specific word in the given strings.
(for e.g. Find how many times the word “live” comes in the
sentence “Dream as if you’ll live forever, live as if
you’ll die today ”)

Answer Posted / vikas kumar from agra

i've try my level best ..plz run this program...but u don't
mistake in typing..100% output right...just try..


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,s,oc=0;
char str[100],substr[30];
clrscr();
printf("\n enter string");
gets(str);
printf("\n enter substr");
gets(substr);
for(s=0;substr[s];s++)
for(i=0;str[i];i++)
{
if(str[i]==substr[0])
{
j=i;
k=0;
while(str[j]==substr[k] && srt[j]!='\0' && substr[k]!='\0')
{
j++;
k++;
}
if(k==s)
{
oc++;
}
printf("\n\t\t occurrence is %d",oc);
getch();
}

Is This Answer Correct ?    18 Yes 43 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where register variables are stored in c?

909


What is "Hungarian Notation"?

1033


What is unary operator?

1052


Explain what are multibyte characters?

1111


Can we assign integer value to char in c?

1158


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

3159


Explain the use of bit fieild.

1097


What is atoi and atof in c?

1028


Write a code to generate a series where the next element is the sum of last k terms.

1169


What is string function c?

968


What is a macro?

1051


What is the explanation for prototype function in c?

924


What is d'n in c?

1072


Which is an example of a structural homology?

1246


Explain what are the standard predefined macros?

1071