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

Can math operations be performed on a void pointer?

1043


what is the role you expect in software industry?

2142


What is the difference between the local variable and global variable in c?

962


What are the different properties of variable number of arguments?

1154


What is c language in simple words?

1068


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

1118


How to draw the flowchart for structure programs?

9333


List the variables are used for writing doubly linked list program.

2030


What's the right way to use errno?

1139


What is the function of volatile in c language?

1124


Are bit fields portable?

1155


What is a loop?

1034


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

1005


What is void main ()?

1073


What is hash table in c?

1019