Exercise 1-13 Write a program that prints a histogram of the word length in the input.
1#include <stdio.h>2 3 /*count digits, white space, others*/4 5 intMainintargcChar Const*argv[])6 {7 intC, I, J, Nwhite, nother;8 intndigit[Ten];9 TenNwhite = nother =0; One for(i =0; I <Ten; ++i) { ANdigit[i] =0; - } - the while((c = GetChar ())! =EOF) { - if(c >='0'&& C <='9') { -++ndigit[c-'0']; -}Else if(c = =' '|| c = ='\ n'|| c = ='\ t') { +++Nwhite; -}Else { +++nother; A } at } - - //printf ("digits ="); - for(i =0; I <Ten; ++i) { -printf"%d:", i); - for(j =0; J < Ndigit[i]; ++j) { inprintf"*"); - } toprintf"\ n"); + } -printf"W:"); the for(i =0; i < Nwhite; ++i) { *printf"*"); $ }Panax Notoginsengprintf"\no:"); - for(i =0; i < nother; ++i) { theprintf"*"); + } Aprintf"\ n"); the //printf (", white space =%d, others =%d\n", Nwhite, nother); + - return 0; $}
C language Exercise 1-13