Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Code - Using Character Functions Skeleton Code: // countWords.c #include #include #define LENGTH 50 int word_count(char []); int main(void) { printf(Enter a sentence with

C Code - Using Character Functions

image text in transcribed

Skeleton Code:

// countWords.c #include #include #define LENGTH 50 int word_count(char []); int main(void) { printf("Enter a sentence with at most %d characters: ", LENGTH); printf("Sentence = %s ", sentence); printf("Word count = %d ", word_count(sentence)); return 0; } // Count the number of words in str int word_count(char str[]) { return 0; } 

Test Caes: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S08P02/testdata/

Practice S08P02: Count Number of Words Week of release: Week 9 Objective: Using character functions Task statement: Write a program countWords.c to read an English sentence and count the number of words in the sentence. Your program should contain a function with the following header: int word_count(char str[]) or int word_count(char *str) This function takes in the sentence and counts the number of words in it. You may assume that there are at most 50 characters in the sentence At least one space is needed to separate words. For example, "J.K. Rowling" contains two words, but "J. K. Rowling" contains three. "A&W fast-food" contains two words. A word must comprise at least one English letter. For example, "Jack & Jill potato chips" contains four words, not five, because "&" is not considered an English word. However, "Jack 'n Jill potato chips" contains five words, because "n" is considered a word as it contains the letter 'n'. Likewise, "3 + 5 is 8" contains only one word. You are to include in your program, but you are NOT allowed to use . This means that you are not allowed to use any string functions (yes, not even strlen()

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

In Problems 510, evaluate each integral. fx1 x ln x dx

Answered: 1 week ago

Question

LO4 Provide an overview of four challenges facing HR today.

Answered: 1 week ago