Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. 2. 3. 4. C++ A space (' ') is a single character in C++. Just like 'a, 'A' , '5, or 96' in C++
1.
2.
3.
4.
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 wordsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started