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
#include<stdio.h>
#include<conio.h>
void main()
{
int i,occ=0;
char str[100],ch;
printf("\n enter string");
scanf("%s",str);
printf("\n enter character");
scanf("%s",ch);
for(i=0;i[str]!='\0';i++)
{
if(str[i]==ch)
{
occ++;
}
}
printf("\n occurance of %c in %s is %d",ch str occ);
getch();
}
Is This Answer Correct ? | 25 Yes | 66 No |
Post New Answer View All Answers
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
Is it better to use a macro or a function?
Describe the difference between = and == symbols in c programming?
Is c easy to learn?
What is a dynamic array in c?
What is the use of getchar functions?
how logic is used
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
Is register a keyword in c?
Why is c so powerful?
int far *near * p; means
How can I get random integers in a certain range?
Explain the properties of union. What is the size of a union variable
How to define structures? ·
Explain what is the stack?