http://www.learnstreet.com/cg/simple/project/word_count - Details
[email protected]: In this programming exercise, we will try to count and extract the words in a user's input. This may span one or more sentences, may include all sorts of alphabets, numbers and characters. And we are not going to use split and count functions,...
Save this page to your bookmarks.
In this programming exercise, we will try to count and extract the words in a user's input. This may span one or more sentences, may include all sorts of alphabets, numbers and characters. And we are not going to use split and count functions, but instead perform it ourselves to learn the logic of how many of these operations are performed. If you come across a sentence like
"Leaves are green, roses are red" it's easy for us to see that there are 6 words. But how do we make a computer carry out this task? Let's try to arrive at a logic for doing such a thing. At first look, it seems to me that if we count the number of spaces, that could definitely tell us something. In the above string, if we count the occurrence of a space.