Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1-13. Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with

Exercise 1-13. Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging.image text in transcribed

that is the sample output they want us to set up

//----------------------------------------------------------- void count_words(void) { // pre-C99 -- have to write void if no args long nc, nl, nw; int c, state = OUT; nc = nl = nw = 0; memset(words, 0, sizeof(words)); while ((c = getchar()) != EOF) { ++nc; if (isalpha(c) || c == '-') { wordbuf[idx++] = c; } if (c == ' ') { ++nl; } if (isspace(c)) { state = OUT; } else if (state == OUT) { state = IN; if (nw > 0) { add_word(); } // don't add entering the first word ++nw; } } if (idx > 0) { // words just before the EOF with no leading whitespace ++idx; add_word(); } printf("%ld chars, %ld words, and %ld lines ", nc, nw, nl); } //----------------------------------------------------------- //----------------------------------------------------------- int main(int argc, const char * argv[]) { // count lines, words, and chars in input count_words(); print_horiz_histogram(); print_vert_histogram(); return 0; }
adding word. 'like' adding word. 'that' 1473 chars. 261 words wax 15:16 and 6 lines 1 * * * 4: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 6: Saada saada 1: 2: 3: 4: 5: 6: 7: 8: 9:18: 11: 12:13: 14: 15: 16:17: 18:19: 20:21: 22:23: 24

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

More Books

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago