please don't copy. C++ In the program, your program first prompt the user to enter a line of text. It counts the number

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

please don't copy. C++ In the program, your program first prompt the user to enter a line of text. It counts the number

Post by answerhappygod »

please don't copy. C++
In the program, your program first prompt the user to enter aline of text. It counts the number of times individual charactersappearing in the line of text entered, and displays the frequencycounts.
You need to use a one dimensional array of size 26. Each arrayelement will serve as the counter for the corresponding letter. Forexample array[0] counts the number of times letter 'a' appeared inthe text, array[1] counts the number of times letter 'b' appearedin the text, etc..
Remember to initialize the array elements to 0 since these arrayelements are used as counters.
Convert all the upper case letters to lower case letters forcounting purpose.
Sample run 1
Enter text: The two kids played and played, and finally gottired, and fall asleep
a : 8
b : 0
c : 0
d : 7
e : 6
f : 2
g : 1
h : 1
i : 3
j : 0
k : 1
l : 7
m : 0
n : 4
o : 2
p : 3
q : 0
r : 1
s : 2
t : 4
u : 0
v : 0
w : 1
x : 0
y : 3
z : 0
Sample run 2
Enter text: Tom and Jerry are lovely characters
a : 4
b : 0
c : 2
d : 1
e : 4
f : 0
g : 0
h : 1
i : 0
j : 1
k : 0
l : 2
m : 1
n : 1
o : 2
p : 0
q : 0
r : 5
s : 1
t : 2
u : 0
v : 1
w : 0
x : 0
y : 2
z : 0
#include <iostream>using namespace std;
int main() {
return 0;}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply