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 / abhishek
#include<stdio.h>
#include<string.h>
main()
{
int i,occ=0;
char str[100],ch;
printf("enter string");
scanf("%s",str);
printf("enter character");
scanf("%s",ch);
for(i=0;str[i]!='\0';i++)
{
if(str[i]==ch)
{
occ+=1;
}
else
{
occ+=0;
}
}
printf("occurance of %s in %s is %d",ch str occ);
getch();
}
| Is This Answer Correct ? | 14 Yes | 12 No |
Post New Answer View All Answers
What library is sizeof in c?
how to write a c program to print list of fruits in alpabetical order?
What are the advantage of c language?
What is extern storage class in c?
what are # pragma staments?
What is the use of f in c?
Explain how can a program be made to print the line number where an error occurs?
Explain the process of converting a Tree into a Binary Tree.
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
Explain threaded binary trees?
how to find anagram without using string functions using only loops in c programming
What is the purpose of clrscr () printf () and getch ()?
Write a program of prime number using recursion.
What is static function in c?
What is structure in c definition?