Question: 1. 2. 3. 4. C++ A space (' ') is a single character in C++. Just like 'a, 'A' , '5, or 96' in C++

1.1. 2. 3. 4. C++ A space (' ') is a single

2.character in C++. Just like 'a, 'A' , '5, or 96' in

3.C++ Write a function that takes a sentence and returns the number

4.of words in the sentence. Your function should take one parameter: o

C++

A space (' ') is a single character in C++. Just like 'a, 'A' , '5, or 96' in C++ Write a function that takes a sentence and returns the number of words in the sentence. Your function should take one parameter: o a string parameter for the sentence . Your function should return the number of words in the sentence Your function should not print anything Your function MUST be named getWordCount Examples: "Go"-> 1 word "I went" ->2 words Colorless green ideas dream furiously -> 5 words "The rat the cat the dog bit chased escaped" 9 words You can assume that all words will be separated by single spaces in the sentence. Think about the relationship between the number of space characters and the number of words Edge cases: Make sure your function returns O if the string is empty (the length of the string is 0) . sentence = "" -> 0 words

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!