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

How can I call a function with an argument list built up at run time?

642


How is a macro different from a function?

657


explain how do you use macro?

668


What are nested functions in c?

567


How can I write functions that take a variable number of arguments?

627






What is a program flowchart and how does it help in writing a program?

666


What is new line escape sequence?

811


What is a sequential access file?

648


How do I create a directory? How do I remove a directory (and its contents)?

608


Explain what are linked list?

627


What are the rules for identifiers in c?

589


What is abstract data structure in c?

532


Can math operations be performed on a void pointer?

590


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1510


What are dangling pointers in c?

645