Write a program that reads a given text, outputs the text as is, and also prints the number of lines and the number of times each letter appears in the text. An uppercase letter and a lowercase letter are treated as being the same; that is, they are tallied together.
Narrative 2: We need to have a generic module which reads in file and gives the output in the format which would facilitate other programs to do comparison like the one we saw above to carry out analysis and comparison.
Response Required:
Write a program that reads a given text, outputs the text as is, and also prints the number of lines and the number of times each letter appears in the text. An uppercase letter and a lowercase letter are treated as being the same; that is, they are tallied together.
Since there are 26 letters, we use an array of 26 components to perform the letter count. We also need a variable to store the line count.
The text is stored in a file, which we will call textin.txt. The output will be stored in a file, which we will call textout.txt
Input: A file containing the text to be processed.
Output: A file containing the text, number of lines, and the number of times a letter appears in the text.
Note: Compile the code on any software and take the secreenshots the language is C++.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images