Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

why wipro wase

2313


can we implement multi-threads in c.

1134


Can the curly brackets { } be used to enclose a single line of code?

1173


When should structures be passed by values or by references?

1045


What are the 4 types of functions?

1061


What is wrong with this code?

1190


What is indirection in c?

1075


What is abstract data structure in c?

1052


What is typeof in c?

1018


Write a program on swapping (100, 50)

1131


How can I send mail from within a c program?

1034


What happens if header file is included twice?

1152


Do character constants represent numerical values?

1349


What is wild pointer in c?

1079


How many main () function we can have in a project?

1115