One step in decoding a simple code without knowing the coding scheme, involves counting the…
One step in decoding a simple code without knowing the coding scheme, involves counting the number of occurrences of each character. Then, knowing that the most common letter in English is ‘e,’ the letter that occurs most commonly in the coded message is replaced by ‘e.’ Similar replacements are then made based on the number of occurrences of characters in the coded message and the known occurrences of characters in the English language. This decoding often provides enough of the correct replacements that the incorrect replacements can then be determined. For this problem, write a program that reads a data file and determines the number of occurrences of each of the characters in the file. Then, print the characters and the number of times that they occurred. If a character does not occur, do not print it. (Hint: Use an array to store the occurrences of the characters based on their ASCII codes.)