Answered step by step
Verified Expert Solution
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
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 includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started