Write a program which takes a string and a word from theuser and search that wor
ID: 3615956 • Letter: W
Question
Write a program which takes a string and a word from theuser and search that word in the string and count how manytimes that word comes in the string. Note: program should search theword not a character.e.g:
#include<iostream.h> #include<stdio.h> voidcount(chr,char[]); voidmain() { charword,string[50]; puts(" Enter thestring:"); gets(string); puts(" Enter the wordyou want to search:"); gets(word); count(word,string); } void count(charword1,char string1[]) { .... .... .... .... .... cout<<"Theword "<<word<<" comes" << ............ <<"times in thestring"; } what should be thedefinition of the count function to count the given word in theprogram.Please write the red portion for the counting ofword. Note: program should search theword not a character.
e.g:
#include<iostream.h> #include<stdio.h> voidcount(chr,char[]); voidmain() { charword,string[50]; puts(" Enter thestring:"); gets(string); puts(" Enter the wordyou want to search:"); gets(word); count(word,string); } void count(charword1,char string1[]) { .... .... .... .... .... cout<<"Theword "<<word<<" comes" << ............ <<"times in thestring"; } what should be thedefinition of the count function to count the given word in theprogram.Please write the red portion for the counting ofword.
Explanation / Answer
please rate - thanks #include #include void count(char[],char[]); void copy(char[],char[],int,int); int main() { char word[50],mystring[50]; puts(" Enter the string:"); gets(mystring); puts(" Enter the word you want to search:"); gets(word); count(word,mystring); system("pause"); return 0; } void count(char word1[],char string1[]) {char newstr[50]; int count=0,lenw,lens,upto=0; lenw=strlen(word1); lens=strlen(string1); while(upto+lenwRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.