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
what is stack , heap ,code segment,and data segment
What are the types of type specifiers?
Explain what is wrong with this program statement?
Describe how arrays can be passed to a user defined function
What is the method to save data in stack data structure type?
Is calloc better than malloc?
What is malloc and calloc?
In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.
What is the use of in c?
What is f'n in math?
Why c language?
what is the difference between 123 and 0123 in c?
What are global variables and explain how do you declare them?
what is recursion in C
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }