Write program to count each occurrence of lower-case letter


Assignment

Write a program, using 25 or fewer lines of code, to count each occurrence of each lower-case letter in a string.

Start your program by declaring a character array, msg, with a size of 30 of greater.

char msg[MAX];

The user should then type a text string into the array:

cin.getline(msg, MAX);

Your program should now report the number of each character (a-z) found in the array:

a face at the beach

a - 4

b - 1

c - 2

d - 0

e - 3

f - 1

g - 0

h - 2

i - 0

j - 0

k - 0

l - 0

m - 0

n - 0

o - 0

p - 0

q - 0

r - 0

s - 0

t - 2

u - 0

v - 0

w - 0

x - 0

y - 0

z - 0

Here is one way of creating that output using characters in a loop:

for (i=0; i<26; i++)

cout << static_cast(i + 'a') << " - " << etc..

The response should include a reference list. Double-space, using Times New Roman 12 pnt font, one-inch margins, and APA style of writing and citations.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write program to count each occurrence of lower-case letter
Reference No:- TGS02957001

Now Priced at $30 (50% Discount)

Recommended (99%)

Rated (4.3/5)