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
Explain how do you determine a file’s attributes?
Why do we use main function?
What is meant by keywords in c?
What is typedef struct in c?
What is a static function in c?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
Is it valid to address one element beyond the end of an array?
What are nested functions in c?
Explain how do you search data in a data file using random access method?
Explain what is the difference between far and near ?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
What is pivot in c?
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is masking?
What will be the outcome of the following conditional statement if the value of variable s is 10?