Input is "Jack and jill went up a hill"
To print output is 1-letter word(s)-1
2-letter words-1
3-letter words-1
4-letter words-4
Answer Posted / bin
#include <stdlib.h>
#include <stdio.h>
int words[8];
int wordcount(char *string) {
int i;
for (i=0; *string; ++string) {
if (*string != ' ' && *string != '\t') {
++i;
} else {
words[i] += 1;
i = 0;
}
}
if (i) words[i] += 1;
}
int main()
{
int i;
char *str = "Jack and jill went up a hill";
wordcount(str);
for (i = 1; i < 5; ++i) {
printf("%d-letter word is - %d\n", i, words[i]);
}
}
Is This Answer Correct ? | 42 Yes | 7 No |
Post New Answer View All Answers
Explain what are binary trees?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
In which language linux is written?
What is the difference between text and binary modes?
What is the best way to comment out a section of code that contains comments?
What is volatile variable in c?
What is null pointer constant?
Why isnt any of this standardized in c?
What is the difference between strcpy() and memcpy() function in c programming?
What is printf () in c?
What is difference between main and void main?
How can I open a file so that other programs can update it at the same time?
how to introdu5ce my self in serco
What is use of null pointer in c?
Explain how can a program be made to print the name of a source file where an error occurs?