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
What is cohesion in c?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Difference between Shallow copy and Deep copy?
Can a pointer be static?
What are derived data types in c?
How can I use a preprocessorif expression to ?
Where are some collections of useful code fragments and examples?
What is formal argument?
Explain how can I pad a string to a known length?
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
Explain how do you view the path?
What is the difference between Printf(..) and sprint(...) ?
How can I copy just a portion of a string?
What is anagram in c?
What do you understand by friend-functions? How are they used?