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

Is printf a keyword?

0 Answers  


what is c++ programming?

3 Answers   TCS,


What is time complexity c?

0 Answers  


main() { int a = 65; printf(“%d %o %x”,a,a,a); } Output 65 101 41 Please explain me.How it is coming like that?

3 Answers   Excel,


Reverse the part of the number which is present from position i to j. Print the new number. eg: num=789876 i=2 j=5 778986

1 Answers  






How can I call a function with an argument list built up at run time?

0 Answers  


Write a code of a general series where the next element is the sum of last k terms.

0 Answers   Aspiring Minds,


i am using gsm modem ! I USE CMGL COMMAND TO DISPLAY THE LIST OF MESSAGES ! I WANT TO READ EACH MESSAGE ONE BY ONE AND GET EACH MESSAGE INDEX USING C PROGRAM ! THE RESPONSE OF THE MODULE AFTER AT+CMGL IS ---CMGL: 1,"REC READ","+85291234567",,"07/05/01,08:00:15+32",145,37 It is easy to list SMS text messages.---- I WANT THE PROGRAM TO GET THE NUMBER "37"{MESSAGE LENGTH} AS WELL AS "1"(MESSAGE INDEX NUMBER" PLEASE HELP

1 Answers   MTNL,


Combinations of fibanocci prime series

0 Answers  


How to avoid structure padding in C?

8 Answers   Tech Mahindra,


How can I open files mentioned on the command line, and parse option flags?

0 Answers  


pierrot's divisor program using c or c++ code

0 Answers  


Categories