#include int main(int argc, char *argv[]) { int c, i; float total = 0.0; float freq; // initialize our 26 counters to zero float char_count[26]; for (i = 0; i < 26; i++) { char_count[i] = 0.0; } // open our file FILE *f = fopen(argv[1], "r"); while ( !feof(f) ) { // check each character in the file c = fgetc(f); if ( (c >=65) && (c <= 90) ) { // upper case letter char_count[c - 65] += 1.0; total += 1.0; } else if ( (c >= 97) && (c <= 122) ) { // lower case letter char_count[c - 97] += 1.0; total += 1.0; } } fclose(f); // calculate the frequency of each character and print the result for (i = 0; i < 26; i++) { freq = char_count[i] / total * 100.0; printf("%c: %.2f\n", (char)(i + 97), freq); } }