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



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

main() { printf(5+"good morning"); printf("%c","abcdefgh"[4]); }the o/p is morning and e...how someone explain

1 Answers  


what is the difference b/w NULL and null?

3 Answers   HSBC, IBM,


What is the 'named constructor idiom'?

0 Answers  


What is a program flowchart?

0 Answers  


Here is alphabets : abcdefgh 1) how to reverse. as hgfedcba 2) after reversal, how to group them in a pair hg fe dc ba.

2 Answers  


What are the differences between new and malloc in C?

0 Answers   Amazon,


Can we declare function inside main?

0 Answers  


diff. between *p and **p

3 Answers  


why r u join this company? give solid resons.

16 Answers   IBM, Infosys, TCS,


void main() { int a=1; printf("%d %d %d",a,++a,a++); } the output is supposed to be 1 2 2....but it is 3 3 1 this is due to calling conventions of C. if anyone can explain me how it happens?

7 Answers  


What is atoi and atof in c?

0 Answers  


Is main is a keyword in c?

0 Answers  


Categories