C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting
C > Miscellaneous sample source codes
Print character history
Print character history #include <stdio.h> #define ARRSIZ 127 - 33 int main(void) { int i, c, nc; float f[ARRSIZ]; nc = 0; for(i = 0; i < ARRSIZ; i++) f[i] = 0.0; while((c = getchar()) != EOF) if(c >= 33 && c <= 127) f[c - '!']++, nc++; for(i = 0; i < ARRSIZ; i++) if(f[i]) printf("%c\t%.2f\n", i + '!', 100 * f[i] / nc); return 0; }
Privacy Policy
|
Link to Us
|
Links