Question: Complete the countWords function using a range loop. The function should return the number of words in a string. Words are separated by whitespace (space,

 Complete the countWords function using a range loop. The function shouldreturn the number of words in a string. Words are separated by

Complete the countWords function using a range loop. The function should return the number of words in a string. Words are separated by whitespace (space, newline or tab). You may use the character classification functions from . Complete the following file: main.cpp 1 2 #include 3 using namespace std; 4 5 int countWords (const string& s) 6 { 7 int words{0}; 8 // Write your loop here 9 10 return words; 11 } Complete the function using a range loop. Given a string, return the sum of the digits 0-9 that appear in the string, ignoring all other characters. Return o if there are no digits in the string. Complete the following file: main.cpp 1 2 #include 3 using namespace std; 4 5 int sumDigits (const string& s) { 7 int sum{@}; 8 // Write your loop here 9 10 return sum; 11 }

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!