Question: Define a word as a string that can only contain alphabetical characters. Given a string of multiple words, each word is separated by one or
Define a word as a string that can only contain alphabetical characters. Given a string of multiple words, each word is separated by one or multiple spaces ( ) or tabs (\t). You are asked to count number of words and find the longest word.
Input String text with a maximum length of 1000 characters, each word is 20 characters max.
Output The number of words and the length of the longest word
Example:
| Input | Output |
| Hello World | 2 5 |
| This is a long sentence. | 4 4 |
Welcome to CS240 | 2 7 |
This is a test input | 5 5 |
Explanation: - In the 2nd example, the word sentence. is not counted as a word since
it contains a dot (.) - In the 3rd example, CS240 is not a word since it contains both
numbers and alphabetic characters
| Compilation commands | C11 / gcc | /usr/bin/gcc -DEVAL -std=gnu11 -O2 -pipe -static -s -o CountWords CountWords.c -lm |
|---|
Programming in C language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
