Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions

Question

7. Define cultural space.

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago