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 / abhishek

#include<stdio.h>
#include<string.h>
main()
{
int i,occ=0;
char str[100],ch;
printf("enter string");
scanf("%s",str);
printf("enter character");
scanf("%s",ch);
for(i=0;str[i]!='\0';i++)
{
if(str[i]==ch)
{
occ+=1;
}
else
{
occ+=0;
}
}
printf("occurance of %s in %s is %d",ch str occ);
getch();
}

Is This Answer Correct ?    14 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What library is sizeof in c?

1093


how to write a c program to print list of fruits in alpabetical order?

2306


What are the advantage of c language?

1054


What is extern storage class in c?

1000


what are # pragma staments?

2046


What is the use of f in c?

984


Explain how can a program be made to print the line number where an error occurs?

1223


Explain the process of converting a Tree into a Binary Tree.

2671


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

2101


Explain threaded binary trees?

1166


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

3195


What is the purpose of clrscr () printf () and getch ()?

1073


Write a program of prime number using recursion.

1095


What is static function in c?

1121


What is structure in c definition?

1056