Question: This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input / output with text files. The program
This assignment tests your ability to write C programs that handle keyboard input, formatted
console output, and inputoutput with text files. The program also tests your ability to write fairly
simple logic as well as use some of the ctype.h functions like isalpha and tolower. The
purpose of this program is to input a textfile and output select characters to a second textfile. Those
characters are the letters that fall between two letters input by the user, as well as punctuation and
whitespace note: whitespace is more than blank spaces
After declaring your variables, input from the user two filenames for the input and output file
respectively and two letters. The filenames will be string variables no more than characters
are needed and they should be the only arrays you declare in this program. The first letter must
be less than the second letter they can either be upper or lower case Use data verification to
ensure both input characters are letters with the first being less than the second. Here is an example
of code you might use.
prompt the user
do
input both characters
whileisalphafirstisalphasecond
tolowerfirsttolowersecond;
To input chars, remember that the variable names need & as opposed to strings but also to input
chars, add a space before the c conversion character, as in scanfc &first; or
scanfc c &first, &second;
Open both files, the first as a read file and the second as a write file. The program will then input
the first file characterbycharacter using a while loop and output those letters that fall between the
two userinput letters inclusively along with all whitespace and punctuation marks but no digits.
All of this output goes to the second write file. As the input letters can be upper or lower case,
you will have to ensure that the current character is compared to these two properly. For instance,
if the letters input from the user are b and p and the current character is either d or D it
should be output. Use toupper or tolower to compare firstsecond and the files character.
While inputting and determining if a character is to be output, your program will also be required
to count each input character, each output character, and the number of letters that were not output
this last count doesnt include digits After exiting the while loop, close both files and compute
the difference in size between the output file and input file as a percentage using the formula
outputsize inputsize The variables inputsize and outputsize should be
ints and that would make the above division an int division requiring that you perform some kind
of casting to make one value a double without this, you will likely wind up with a value of
since inputsize outputsize Output a short report to the console window using printf
statements that lists the input file name, output file name, size of input file, size of output file,
number of letters not output, and percentage file change. See the example output on the next page
of this assignment. The output should be reasonably formatted with the numbers lining up
There are two input files on the website. Download them and run your program on the first using
letters b and por B and P comparing your results to the results below. Once your program
is properly debugged, run your program on the second input using e and x
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
