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
How can I convert a number to a string?
How main function is called in c?
What does != Mean in c?
Explain bitwise shift operators?
What does sizeof int return?
What does the characters “r” and “w” mean when writing programs that will make use of files?
How can you avoid including a header more than once?
What is the data segment that is followed by c?
Write a program to check whether a number is prime or not using c?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
What are qualifiers and modifiers c?
Is it better to use a macro or a function?
Explain how can I write functions that take a variable number of arguments?
given post order,in order construct the corresponding binary tree
Multiply an Integer Number by 2 Without Using Multiplication Operator