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


Please Help Members By Posting Answers For Below Questions

What does char * * argv mean in c?

625


write a c program for swapping two strings using pointer

2095


Describe explain how arrays can be passed to a user defined function

606


What are the 4 types of unions?

612


how to execute a program using if else condition and the output should enter number and the number is odd only...

1660






What is integer constants?

625


Is null a keyword in c?

738


What do you mean by c?

590


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2008


What is c mainly used for?

600


What is getche() function?

610


Explain what are header files and explain what are its uses in c programming?

629


Can you please explain the difference between strcpy() and memcpy() function?

603


Is it better to use malloc() or calloc()?

650


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1122