Computer Science, asked by agnivmitra11, 6 months ago

Write a program to accept a string in upper case and display the longest word and the length of the longest word present in the string.​

Answers

Answered by bittumogatalareddy
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