Question: Write a void function, called NumberOfWordsAndSentences, that, when given a string, will return the number of spaces AND the number of periods. For example, if

Write a void function, called NumberOfWordsAndSentences, that, when given a string, will return the number of spaces AND the number of periods. For example, if the function is given "We all live in a yellow submarine." , your function should find the number of spaces to be 6 and the number of periods to be 1. You may assume that the string can be very large.

Answer in C++

#include #include using namespace std;

//write your function here

int main() {

string userString; int numSpaces = 0; int numPeriods = 0; getline( cin, userString); NumberOfWordsAndSentences( userString, numSpaces, numPeriods);

cout << "The number of spaces is " << numSpaces << " and the number of periods is " << numPeriods << "." << endl; return 0; }

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!