Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer the following in c code: Requirements Create a program that will count the occurrences of letters in a user-input string and create a

Please answer the following in c code:

image text in transcribedimage text in transcribedimage text in transcribed

Requirements Create a program that will count the occurrences of letters in a user-input string and create a report. Your program should begin by asking the user to enter text for analysis. The user should be able to type up to 1023 characters and hit enter, and your program should be able to store these characters as a C string. Your program should have a buffer (i.e. char array) for storing this string that can handle up to the maximum length needed to hold the this amount of characters (but not more than the amount of space required either). Your program should then analyze the string to count the number of characters of each letter from 'A' to 'Z' in the string. Your program should count both uppercase and lowercase instances of the characters as an occurrence of the character. In other words, the string "AaaAbB would have a count of 4 'A' characters and 2 'B' characters. Your program should keep track of the count of each A to Z character using an array, not with individual variables. Your program should output the total occurrences of each character in a table, along with the percentage of the string that is made up of each character from A-Z. The table should have three columns Letter - 10 characters, left-aligned Occurrences - 15 characters, left-aligned Percentage - 15 characters, left-aligned, output two decimal digits of precision . Beneath the table, your program should also output the most frequently occurring character from A-Z, and the least frequently occurring character from A-Z. If two or more characters are "tied" for either most frequently occurring character or least frequently occurring character, then you can output any of those characters as being the most frequently or least frequently occurring character. Hint: Remember that characters in C are really just an int number. It's possible to write a very simple and short version of this program if you keep this in mind: http://www.asciitable.com/. Your program should run either identically or near identically to this example, in particular the occurrences and percentages should be identical: Enter text for analysis: The quick brown fox jumps over the lazy dog. Letter Analysis Complete! Letter Occurrences Percentage A B D E F G H I J K 1 1 1 1 3 1 1 2 1 1 1 1 1 1 4 1 1 2 1 2 2 1 1 1 1 1 2.27 2.27 2.27 2.27 6.82 2.27 2.27 4.55 2.27 2.27 2.27 2.27 2.27 2.27 9.09 2.27 2.27 4.55 2.27 4.55 4.55 2.27 2.27 2.27 2.27 2.27 The most frequently occurring character is 0. The least frequently occurring character is A. Here is another example of the program running: Enter text for analysis: aAAa zzzzzzz yxwv Letter Analysis Complete! Letter Occurrences Percentage **** 4 15.38 B 0 0.00 0 0.00 D 0.00 E 0.00 F 0.00 G 0.00 H 0.00 I 0.00 0.00 K 0 0.00 L 0.00 M 0 0.00 N 0.00 0.00 0.00 Q 0.00 R 0 0.00 0 0.00 0.00 U 0.00 V 1 3.85 W 1 3.85 1 3.85 Y 1 3.85 7 26.92 The most frequently occurring character is z. The least frequently occurring character is B

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

State the three objectives of the book.

Answered: 1 week ago

Question

Understand why empowerment is so important in many frontline jobs.

Answered: 1 week ago