Question: C++ follow prompt Write a program that will read a line of text and output a list of all the letters that occur in the

C++ follow prompt

Write a program that will read a line of text and output a list of all the letters that occur in the text together with the number of times each letter occurs in the line. End the line with a period that serves as a sentinel value. The letters should be listed in the following order: the most frequently occurring letter, the next most frequently occurring letter, and so forth. Use two arrays, one to hold integers and one to hold letters. You may assume that the input uses all lowercase letters. For example, the input

do be do bo.

Should produce output similar to the following:

Letter

Number of Occurrences

o

3

d

2

b

2

e

1

Your program will need to sort the arrays according to the values in the integer array. You can modify the function sort given in Display 7.12 and use it in your program. You cannot use sort to solve this problem without changing the function.

Prompt

C++ follow prompt Write a program that will read a line of

text and output a list of all the letters that occur in

the text together with the number of times each letter occurs in

7.12

the line. End the line with a period that serves as a

sentinel value. The letters should be listed in the following order: the

#include #include struet char_free char ch; int count; ); I/NOTE that all that is necessary in the headers is to //replace int with char_freg void sort (char_freq a[], int number_used); 1/Precondition number_used > ch; we want to ignore blanks, so we use cin>>... ch = tolower(ch); // Push everything to lowercase. while('.' != ch) { if (!lookup (ch, list, size) insert (ch, list, size); cin >> ch; } } void insert (char e, chaz_freg list[], ints size) list[size] .count=1; list size).ch = c; size ++; assert size void fillarray(int a[], int size, ints numberUsed); //Precondition: size is the declared size of the array a. //Postcondition: numberUsed is the number of values stored in a. 1/2 [0] through a numberUsed - 1] have been filled with 1onnegative integers read from the keyboard. void sort (int all, int numberUsed); //recondition: numberUsed for (int index = 0; index

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!