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 / ram
#include <string.h>
void main()
{
char name[] ="Dream as if you will live forever, live as if
you will die today";
char r[] ="live";
int iLen = strlen(r);
int iCount = 0;
while(1)
{
if( strstr(name,r) == NULL)
break;
strcpy(name, strstr(name,r));
strcpy(name,name+iLen);
iCount++;
}
printf("%d",iCount);
}
| Is This Answer Correct ? | 23 Yes | 28 No |
Post New Answer View All Answers
How do you write a program which produces its own source code as output?
Is fortran still used in 2018?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
How is null defined in c?
What are the different types of C instructions?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
What are qualifiers and modifiers c?
What are the types of unary operators?
What is structure data type in c?
Do you have any idea how to compare array with pointer in c?
What is meant by initialization and how we initialize a variable?
By using C language input a date into it and if it is right?
What are local static variables?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
Can we declare variables anywhere in c?