Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use this skeleton for \'main\': int main() { char cstring[81]; cout << \"\ Enter

ID: 3618997 • Letter: U

Question

Use this skeleton for 'main':




int main()

{

char cstring[81];



cout << " Enter a string, 80 or fewer characters: ";

cin.getline(cstring, 81);

cout << " The number of words in that string: ";

cout << wordCount(cstring) << endl << endl;

return 0;

}




Note: The main problem in this exercise istraveling within a string,

character by character, while determining whether we are inside ofa word or in

between words (space). Here is a bit of pseudocode, which shouldhelp get started:



index = 0

while string[index] != NULL



if char = space

while char = space

keep looping

if char = nonspace

word++ //we must be in a word

while char = nonspace

keep looping



index++



endwhile



Notes:



  • The pseudocode above is not a required skeleton; it is onlymeant to

    exemplify the concept.


  • Also don't forget that a pointer to the string will be used,inside the

    wordCount function.


  • Be sure to use the function 'isalnum' and 'isspace' forcomparing

    characters.


  • Anticipate possible multiple spaces in front of the sentence,in between

    words, etc.


  • When looping inside of a word, be prepared to run into anapostrophy or

    other punctuation (ex: don't), therefore, requiring an additionalcondition for

    the while loop such as:





while( isalnum(word[index]) || ( ispunct(word[index])) )






From the book:



Average Number of Letters: Modify the program youwrote for problem 3

(Word Counter), so it also displays the average number of lettersin each word.



int main()

{

char cstring[81];



cout << " Enter a string, 80 or fewer characters: ";

cin.getline(cstring, 81);

cout << " The number of words in that string: ";

cout << wordCount(cstring) << endl << endl;

return 0;

}



index = 0

while string[index] != NULL



if char = space

while char = space

keep looping

if char = nonspace

word++ //we must be in a word

while char = nonspace

keep looping



index++



endwhile



Notes:



  • The pseudocode above is not a required skeleton; it is onlymeant to

    exemplify the concept.


  • Also don't forget that a pointer to the string will be used,inside the

    wordCount function.


  • Be sure to use the function 'isalnum' and 'isspace' forcomparing

    characters.


  • Anticipate possible multiple spaces in front of the sentence,in between

    words, etc.


  • When looping inside of a word, be prepared to run into anapostrophy or

    other punctuation (ex: don't), therefore, requiring an additionalcondition for

    the while loop such as:





while( isalnum(word[index]) || ( ispunct(word[index])) )







Average Number of Letters: Modify the program youwrote for problem 3

(Word Counter), so it also displays the average number of lettersin each word.

Explanation / Answer

please rate - thanks #include int wordCount(char*,int&); using namespace std;       int main()       {int tot=0,w;       char cstring[81];       cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote