Question: 4) (20 marks) Write a C program named a5q4.c which reads standard input and reports at the end the counts and frequencies of all letters

4) (20 marks) Write a C program named a5q4.c which reads standard input and reports at the end the counts and frequencies of all letters and the space character. The program must normalize the letters, i.e., must count as the same uppercase and lowercase letters. The count is the number of times a letter occured in text, while frequency is a fraction of time the letter occured divided by the total number of letters. (Be careful to avoid dividing by zero!)

Any characters between letters, i.e, between words, are counted as a simple space character, which is printed as an underscore (`_') character. You should also assume that there is a space character at the very beginning and the very end of the text.

If the input is empty or if it does not contain any letters, the output should be the same as only one space was processed.

The program output must be as in the sample output shown below. You should align the numbers as shown in the table, and the frequency is printed in percentages rounded to exactly four decimals. (The percentages mean that the actual fraction is multiplied with 100.)

Make sure that your program produces format as given in the sample output.

Sample Input:

i.e., must count as the same uppercase and lowercase letters. The count is the number of times a letter occured in text, while frequency is a fraction of time the letter occured divided by the total number of letters. (Be careful to avoid dividing by zero!)

Any characters between letters, i.e, between words, are counted as a simple space character, which is printed as an underscore (`\verb,_,') character.

Sample Output

Letter occurences freq.

-------------------------

_ 71 18.25 %

a 24 6.17 %

b 8 2.06 %

c 21 5.40 %

d 13 3.34 %

e 53 13.62 %

f 6 1.54 %

g 1 0.26 %

h 11 2.83 %

i 19 4.88 %

j 0 0.00 %

k 0 0.00 %

l 10 2.57 %

m 7 1.80 %

n 16 4.11 %

o 16 4.11 %

p 5 1.29 %

q 1 0.26 %

r 27 6.94 %

s 19 4.88 %

t 33 8.48 %

u 12 3.08 %

v 4 1.03 %

w 6 1.54 %

x 1 0.26 %

y 4 1.03 %

z 1 0.26 %

-------------------------

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!