Question
Using C programming language and the built in function of getchar(): 1. Counts Your program should count occurrences of alphabetical, English letters a through z,
Using C programming language and the built in function of getchar():
1. Counts
Your program should count occurrences of alphabetical, English letters a through z, case insensitive. It should ignore all other characters except for the EOF character which, when encountered, should display the counts of only the alphabetical characters with at least one occurrence. The expected format of this output is, for each character and count on its own line:
2.2 - Percents
After outputing character counts, your program should output the each characters percentage of the alphabetical characters encountered. For example, in the example input Cackalack! there were were 9 alphabetical characters and 3 of them were the letter c, so cs percentage was 33.3%. The expected format of this output is, for each character and percentage on its own line, each percentage should have one digit of significance and be followed by the % symbol:
3. Frequency Bar Chart
The final challenge of this lab is to produce a vertical bar chart of relative frequencies, as shown in the prior example output. It should be scaled such that the tallest bar in your chart is always 10 lines tall. Use the vertical bar character | when drawing the bars. When the height of a bar has a decimal component, you should always truncate it (always round down). Unlike the previous two parts, there should be an entry for every alphabetical character to form the x-axis of the chart as shown in the previous example, even if it has no bar.
SAMPLE INPUT:
$ echo "Cackalack!" | ./a.out
SAMPLE OUTPUT (MUST MATCH EXACTLY):
Counts: a: 3 c: 3 k: 2 1: 1 Percents: a: 33.3% c: 33.3% k: 22.2% 1: 11.1% Chart: | | abcdefghijklmnopqrstuvwxyz
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started