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 / balaji ganesh

#include<stdio.h>
#include<string.h>
void main()
{
char s[200],c[20],v=' ';
int i=0,j,f,n=0;
printf("enter string: ");
gets(s);
printf("enter new string: ");
gets(c);
while(i<strlen(s))
{
j=f=0;
while(j<strlen(c))
{
if(s[i++]!=c[j++])
{
f=1;i--;break;
}
}
if((f==0)&&(i==strlen(s)||s[i]==' ')&&(v==' '))
n++;
v=s[i++];
}
printf("the word %d times occured",n);
}

Is This Answer Correct ?    91 Yes 41 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When should the register modifier be used? Does it really help?

974


Write a code to determine the total number of stops an elevator would take to serve N number of people.

1264


What is the difference between array and linked list in c?

1164


can anyone please tell about the nested interrupts?

2125


find out largest elemant of diagonalmatrix

2257


how to find anagram without using string functions using only loops in c programming

3197


What is keyword with example?

1074


What is const and volatile in c?

1051


Why is c so important?

1068


Do pointers need to be initialized?

1093


How can I discover how many arguments a function was actually called with?

1072


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

2350


What is the use of structure padding in c?

1080


What is queue in c?

1110


Can you please explain the difference between malloc() and calloc() function?

1130