Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language (not c++) Write a program that reads a text file as input and counts the number of sentences and words. The input to

C language (not c++)
image text in transcribed
Write a program that reads a text file as input and counts the number of sentences and words. The input to your program should be a user specified text file. In other words, obtain the name of the input file at run time from the user of the program. Protect your program against crashes that might be caused by a bad file name. A sentence begins with one of the following: ' 0 '...' 9 ', 'A'...' Z ', or ' a '...' z. A sentence, once started, ends with the first occurrence of one of the following sequences: 1. A TERMINATOR followed by two spaces 2. A TERMINATOR followed by one space and end-of-line 3. A TERMINATOR followed by end-of-line 4. A TERMINATOR followed by a double quote and a space 5. A TERMINATOR followed by a double quote and an end-of-line TERMINATORS: ' '(period) '?' (question mark) 'I' (exclamation point) A word begins with one of the same set of characters that begin a sentence. A word, once started, ends with the first occurrence of a space, a tab, or an end-of-line, unless the end-of-line is preceded by a hyphen. Appropriate counting actions should be taken when the end-of-file (EOF) is encountered. The output total number of sentences and words should be printed to the screen. TIPS: Make two passes through the input file. Count the sentences on one pass, wards on the other. While a good programming practice, functions are NOT required so keep the entire program in the moin function. implement the word counter first because it is, arguably, the easier than the sentence counter. MOST IMPORTANTLY, focus on your algorithm before you implement it with cade. You've been warned

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions