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
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Describe the order of precedence with regards to operators in C.
Can an array be an Ivalue?
What is character constants?
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What are all different types of pointers in c?
What is structure packing in c?
What is the benefit of using #define to declare a constant?
Write a program to know whether the input number is an armstrong number.
What are the 4 data types?
How many levels of indirection in pointers can you have in a single declaration?
What is the right type to use for boolean values in c? Is there a standard type?
Explain how can you be sure that a program follows the ansi c standard?
Explain what is output redirection?