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

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

Is This Answer Correct ?    25 Yes 66 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2279


Is it better to use a macro or a function?

663


Describe the difference between = and == symbols in c programming?

788


Is c easy to learn?

569


What is a dynamic array in c?

604






What is the use of getchar functions?

692


how logic is used

1506


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

664


Is register a keyword in c?

643


Why is c so powerful?

695


int far *near * p; means

3133


How can I get random integers in a certain range?

630


Explain the properties of union. What is the size of a union variable

728


‎How to define structures? · ‎

645


Explain what is the stack?

651