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 / 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 |
what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?
#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); }
Which built-in library function can be used to match a patter from the string?
How the processor registers can be used in C ?
How do you use a pointer to a function?
What is this infamous null pointer, anyway?
Can you write the algorithm for Queue?
0 Answers College School Exams Tests, TCS,
What is the use of header files?
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?
what is computer engg
What is difference between array and pointer in c?