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

what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }

1 Answers   Motorola,


int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?

4 Answers   TCS,


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

0 Answers   Wilco,


Which built-in library function can be used to match a patter from the string?

0 Answers  


How the processor registers can be used in C ?

7 Answers   HP,


How do you use a pointer to a function?

0 Answers  


What is this infamous null pointer, anyway?

0 Answers  


Can you write the algorithm for Queue?

0 Answers   College School Exams Tests, TCS,


What is the use of header files?

0 Answers  


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

0 Answers  


what is computer engg

1 Answers  


What is difference between array and pointer in c?

0 Answers  


Categories