Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Write a program that counts the number of times that each letter of the alph

ID: 648696 • Letter: C

Question

C++

Write a program that counts the number of times that each letter of the alphabet occurs in a file. Do not distinguish upper and lower case letters.

declare an array of 26 characters, letters

declare an array of 26 integers, counts

fill the integer array with zeros

capacity := 26

population := 0

open file

character := read-character

while not end of file

    if character is letter then

      convert character to upper case

      position := find(letters, character)

     if position = - 1 then

       letters[population] := character

       counts[population] := 1

       add 1 to population

   else

       add 1 to counts[position]

end if

character := read-character

end while

write letters, counts to file

Explanation / Answer

#include #include #include #include char ch=tolower(ch-'A'); using namespace std; int main() { char ch=('a','b','c','d','e','f','g','h','i','j','k','l','M','n','o','P','q','r','s','t','u','v','w','x','y','z'); fstream infile; infile.open("108.txt"); if(ch =='A' || ch =='Z') { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote