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 / ankur
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[40],ch;
int num;
cout<<"Entre a string :";
cin.getline(str,40);
cout<<"Entre a character :";
cin>>ch;
for(int i=0;i!='\0';++i)
{
if(str[i]==ch)
num=num+1;
}
cout<<num;
getch();
}
| Is This Answer Correct ? | 20 Yes | 74 No |
Post New Answer View All Answers
What does a pointer variable always consist of?
write a program to rearrange the array such way that all even elements should come first and next come odd
What's the right way to use errno?
Is return a keyword in c?
How main function is called in c?
program to convert a integer to string in c language'
Is c is a high level language?
How can I do serial ("comm") port I/O?
When should the const modifier be used?
What is sizeof return in c?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
What is the difference between void main and main in c?
What is #include stdlib h?
What is the difference between int main and void main?
Explain what is the difference between functions getch() and getche()?