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 is a program?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.
What is keyword with example?
Can include files be nested?
What are the features of c languages?
What’s a signal? Explain what do I use signals for?
What are keywords c?
What are loops c?
What is the use of bit field?
What is calloc()?
What is quick sort in c?
What is dynamic memory allocation?
Do variables need to be initialized?
What are the two forms of #include directive?
What is c system32 taskhostw exe?