1. Write a C program to count the number of occurrence
of
a specific word in the given strings.
(for e.g. Find how many times the word “live” comes in the
sentence “Dream as if you’ll live forever, live as if
you’ll die today ”)
Answer Posted / abhishek
#include<stdio.h>
#include<string.h>
main()
{
int i,occ=0;
char str[100],ch;
printf("enter string");
scanf("%s",str);
printf("enter character");
scanf("%s",ch);
for(i=0;str[i]!='\0';i++)
{
if(str[i]==ch)
{
occ+=1;
}
else
{
occ+=0;
}
}
printf("occurance of %s in %s is %d",ch str occ);
getch();
}
| Is This Answer Correct ? | 14 Yes | 12 No |
Post New Answer View All Answers
Write a program to reverse a string.
Explain what is dynamic data structure?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
What is an operator?
What is the use of a semicolon (;) at the end of every program statement?
How can I read and write comma-delimited text?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
What are the restrictions of a modulus operator?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
why do some people write if(0 == x) instead of if(x == 0)?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
What is boolean in c?
What is const and volatile in c?
can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none