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

#include<stdio.h>
#include<conio.h
#include<string.h>
void main()
{
char st[200],nw[20];
int i,j=0;
clrscr();
printf("enter string");
gets(st);
printf("enter new string");
gets(nw);
for(i=0;st[i]!='\0';i++)
{if (strcmp(nw,st)==0)
j=j++;
}}
getch();
}

Is This Answer Correct ?    68 Yes 183 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cohesion in c?

545


Write the test cases for checking a variable having value in range -10.0 to +10.0?

1822


Difference between Shallow copy and Deep copy?

1575


Can a pointer be static?

629


What are derived data types in c?

617






How can I use a preprocessorif expression to ?

604


Where are some collections of useful code fragments and examples?

721


What is formal argument?

654


Explain how can I pad a string to a known length?

658


The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference

677


Explain how do you view the path?

661


What is the difference between Printf(..) and sprint(...) ?

792


How can I copy just a portion of a string?

820


What is anagram in c?

521


What do you understand by friend-functions? How are they used?

652