Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program that, given a file named Program_2.dat as input, determines and prints the following information: The number of characters in the file.
Write a C program that, given a file named Program_2.dat as input, determines and prints the following information:
- The number of characters in the file.
- The number of uppercase letters in the file.
- The number of lowercase letters in the file.
- The number of words in the file.
- The number of lines in the file.
Your program should assume that the input file, Program_2.dat, may contain any text whatsoever, and that text might be, or might not be, the excerpt from A Tale of Two Cities shown below.
- Your program's input and output must look as much as possible like the sample run shown below (including, but not necessarily limited to, wording, punctuation, horizontal & vertical spacing, and indentation).
Assume that the program will be tested using gcc (GCC) 8.2.0.
Sample Run # 1
When file Program_2.dat is present in the current working directory.
This program reads text from Program_2.dat and determines: 1. The number of characters in the file. 2. The number of uppercase letters in the file. 3. The number of lowercase letters in the file. 4. The number of words in the file. 5. The number of lines in the file. The file Program_2.dat contains: 631 characters 4 uppercase letters 471 lowercase letters 119 words 17 lines
Sample Run # 2
When file Program_2.dat is not present in the current working directory.
This program reads text from Program_2.dat and determines: 1. The number of characters in the file. 2. The number of uppercase letters in the file. 3. The number of lowercase letters in the file. 4. The number of words in the file. 5. The number of lines in the file. Error! Failed to open Program_2.dat!
Sample Input File
It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way-- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started