C++ Program to Count Number of Words in String
Here you will get C++ program to count number of words in string. First we initialize a counter variable to 1. Now iterate through string and count all the spaces, for each space increase the value of counter. Finally print the counter variable, it contains the number of words. Output Enter a string:how are you …