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


Please Help Members By Posting Answers For Below Questions

Explain how do you determine a file’s attributes?

596


Why do we use main function?

643


What is meant by keywords in c?

620


What is typedef struct in c?

592


What is a static function in c?

627






`write a program to display the recomended action depends on a color of trafic light using nested if statments

1635


Is it valid to address one element beyond the end of an array?

677


What are nested functions in c?

568


Explain how do you search data in a data file using random access method?

700


Explain what is the difference between far and near ?

655


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

670


What is pivot in c?

570


Once I have used freopen, how can I get the original stdout (or stdin) back?

631


What is masking?

641


What will be the outcome of the following conditional statement if the value of variable s is 10?

771