write a program taking input from the user accept a string upto 1000 characters find the word that is repeated the maximum number of times if there are more than one words print the largest word to the output
Answers
Answered by
0
Answer:
Given a string, we have to find the longest word in the input string and then calculate the number of characters in this word.
Examples:
Input : A computer science portal for geeks
Output : Longest word's length = 8
Input : I am an intern at geeksforgeeks
Output : Longest word's length = 13
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
The idea is simple, we traverse the given string. If we find end of word, we compare length of ended word with result. Else, we increment length of current word
Similar questions