Question: 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

C Code - Using Character Functions Skeleton Code: // countWords.c #include #include

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!