C++ Assignment (send me a text file, need within the next 4 hours)

profilesmilinwizard

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.

<pre class="brush: cpp">
char msg[MAX];
</pre>

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

<pre class="brush: cpp">
cin.getline(msg, MAX);
</pre>

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:

<pre class="brush: cpp">
for (i=0; i<26; i++)
cout << static_cast<char>(i + 'a') << " - " << etc..
</pre>

    • 8 years ago
    • 10
    Answer(1)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      code.cpp