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
Explain the meaning of keyword 'extern' in a function declaration.
Explain the use of keyword 'register' with respect to variables.
Write a program to identify if a given binary tree is balanced or not.
What are the rules for the identifier?
How reliable are floating-point comparisons?
What is size of union in c?
How can I make it pause before closing the program output window?
what are enumerations in C
Is there any data type in c with variable size?
Is there anything like an ifdef for typedefs?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
Explain how can I read and write comma-delimited text?
What are pointers? What are stacks and queues?
what is a function method?give example?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?