Order now

Write a program that reads as an input file and shows the letter frequencies in the file.

If you were to encrypt a file using the cipher of Exercise P9.2, the letters will mixed up, and will appear as that you cannot decrypt it without the keyword. Also, it would seem illogical to try and guess the keyword, but someone who is trained in decryption would have no trouble breaking the cipher. The average letter frequencies of English letters are common knowledge. The most common letter E, occurs about 13% of the time.

  1. See Exhibit B.
  2. Write a program that reads as an input file and shows the letter frequencies in the file. This tool is invaluable to a code breaker. If the most frequent letters are H and K there is a high probability that they are the encryptions of E and T.

I have this code





using namespace std;

void count_frequencies(string str,int list[],int size)


for(int i=0; i<str.length(); i++)


if(str[i]>=’A’ && str[i]<=’Z’)


else if(str[i]>=’a’ && str[i]<=’z’)


else continue;



int main()


ifstream infile;

string file_name;

int list[26] = { 0 };

string str;

cout <<“Enter file name to letter frequencies in the file. :”;

cin >> file_name; cout << endl;




cout <<“Unable to open file . So Exiting from program :” << endl;

return 0;




infile >> str;

count_frequencies(str,list, 26);



cout <<“Letter \t Count ” << endl;

int max = list[0];

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


cout << static_cast<char> (i+’a’) <<” \t ” << list[i] << endl;

if(list[i] > max ) max = list[i];


cout <<“Most occured letter is ” << static_cast<char> (max+’a’) << endl;

cout << “So E is Encrypted to ” << static_cast<char> (max+’a’) << endl;


return 0;



but it does not work correclty.I need this ASAP

Place a similar order with us or any form of academic custom essays related subject and it will be delivered within its deadline. All assignments are written from scratch based on the instructions which you will provide to ensure it is original and not plagiarized. Kindly use the calculator below to get your order cost; Do not hesitate to contact our support staff if you need any clarifications.

Type of paper Academic level Subject area
Number of pages Paper urgency Cost per page:

Whatever level of paper you need – college, university, research paper, term paper or just a high school paper, you can safely place an order.