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



Input is "Jack and jill went up a hill" To print output is 1-letter word(s)-1 2-letter w..

Answer / 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

More C Interview Questions

How can I dynamically allocate arrays?

0 Answers  


How do c compilers work?

0 Answers  


#include<stdio.h> #include<conio.h> int main() { int a[4][4]={{5,7,5,9}, {4,6,3,1}, {2,9,0,6}}; int *p; int (*q)[4]; p=(int*)a; q=a; printf("\n%u%u",p,q); p++; q++; printf("\n%u%u",p,q); getch(); return 0; } what is the meaning of this program?

2 Answers  


What is the use of header files?

0 Answers  


What is #define used for in c?

0 Answers  






What is a c token and types of c tokens?

0 Answers  


write a c programs to do multiplication of two numbers with out using arithmatic operator ??????????

7 Answers   Infosys, TCS,


Hi, main() { } Is a user defined function or Built in Functionn

26 Answers   Honeywell, Yahoo,


write a program to generate 1st n fibonacci prime number

2 Answers  


Differentiate between null and void pointers.

0 Answers   TCS,


Go through this linked list concept.While traversing through the singly linked list sometimes the following code snippet "while(head != NULL)" is used and other times "while(head->link != NULL)"is used(Here head is the pointer pointing to the first node,node has two parts data part and link part).What is the difference between head != NULL and Head->link != NULL and in which situation are they used?

1 Answers   Oracle,


what is the diffrenet bettwen HTTP and internet protocol

0 Answers  


Categories