C++ code for: Write a program to print a histogram of the frequencies of different characters in its input.
Hi everybody. I ask this because this question (Exercise 1-14 from Kernighan - Richie's C book) is making me suffer. It gives you the following program, so the only thing left is adding the histogram (which, I have no idea how to). #include <stdio.h> main( ) { int c, i, nwhite, nother; int ndigit[10]; nwhite = nother = 0; for (i = 0; i < 10; ++i) ndigit[i] = 0; while ((c=getchar( ))!=EOF) if (c >= '0' && c <= '9') ++ ndigit [c-'0']; else if (c==' ' || c=='\n' || c=='\t') ++nwhite; else ++nother; printf ("digits ="); for (i = 0; i < 10; ++i) printf(" %d", ndigit[i]); printf(", blank spaces = %d, other = %d\n", nwhite, nother); i=0; } So.. this program count the frecuency of each of the digits you type (from 0 to 9), the # of blank spaces and other characters. I don't care about the later two. I just want help about the creation of an histogram using the frecuencies of the numbers you type. (Maybe this book is too old and I should know more recent/useful functions, like cin in exchange of getchar().. I dunno. Someone help me :'( )