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
Where register variables are stored in c?
What is "Hungarian Notation"?
What is unary operator?
Explain what are multibyte characters?
Can we assign integer value to char in c?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
Explain the use of bit fieild.
What is atoi and atof in c?
Write a code to generate a series where the next element is the sum of last k terms.
What is string function c?
What is a macro?
What is the explanation for prototype function in c?
What is d'n in c?
Which is an example of a structural homology?
Explain what are the standard predefined macros?