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
What does char * * argv mean in c?
write a c program for swapping two strings using pointer
Describe explain how arrays can be passed to a user defined function
What are the 4 types of unions?
how to execute a program using if else condition and the output should enter number and the number is odd only...
What is integer constants?
Is null a keyword in c?
What do you mean by c?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What is c mainly used for?
What is getche() function?
Explain what are header files and explain what are its uses in c programming?
Can you please explain the difference between strcpy() and memcpy() function?
Is it better to use malloc() or calloc()?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?