Question: Modify count.c so that it also prints the total number of words in the input text and the average word length. Print the average word

Modify count.c so that it also prints the total number of words in the input text and the average word length. Print the average word length with two digits to the right of the decimal point. Call your program avgWordLength.c. For the purpose of this assignment, assume that a word is a sequence of non-whitespace characters. The best way to test for a whitespace character is to use the library function isspace, which is in the library . For example, the function call isspace(c) returns 1 if char c is whitespace, and 0 otherwise. Do not use arrays. For an example of the program in action:

Modify count.c so that it also prints the total number of words

// count.c Count the number of lines and chars in the input. #include int main() { int lineCount = 0; int numLines = 0; int numChars = 0; printf("Enter text. Use an empty line to stop. "); while (1) { int ic = getchar(); if (ic   ser@adminuser-VirtualBox-/Desktop/classDemos s gcc avgwordLength.c-o avgwordLength adminuser@adminuser-VirtualBox-/Desktop/classDemos$ ./avgwordLength Enter text. Use an empty line to stop. fgjglkk ofjvf abc Your text has 2 lines and 20 characters. Your text has 3 words, with an average length of 5.00. adminuser@adminuser-VirtualBox /Desktop/classDemosavgwordLength 

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!