Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that prompts the user to input the name of a text file and then

ID: 3626037 • Letter: W

Question

Write a program that prompts the user to input the name of a text file and then outputs the number of words in the file. You can consider a "word" to be any text that is surrounded by whitespace (e.g., a space, carriage return, newline) or borders the beginning or end of the file.

Explanation / Answer

here is the psudocode open input file check if its opened open output file initialize a count variable to 0 read the first line of the input file (cin >> someVaraible (probably string)) while (infile) increment count write the word to the screen write the file to the output file read in another line (just cin again) write the number of words to the screen (the count variable) write the number of words to the output file close the input and output file

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote