Program to find the largest & smallest word in a stringExplanationIn this program, we need to find the smallest and the largest word present in the string. Consider above example in which 'an' is the smallest word and 'extraordinary' is the largest word. One of the approach to find smallest and largest word is to split string into words then, compare length of each word with variables small and large. If length of a word is less than length of small then, store that word in small. If length of a word is greater than length of large then, store that word in large. Algorithm
SolutionPythonOutput: Smallest word: an Largest word: extraordinary COutput: Smallest word: an Largest word: extraordinary JAVAOutput: Smallest word: an Largest word: extraordinary C#Output: Smallest word: an Largest word: extraordinary PHPOutput: Smallest word: an Largest word: extraordinary Next Topic# |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India