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 / vikas kumar
#include<stdio.h>
#include<conio.h>
void main()
{
int i,occ=0;
char str[100],ch;
printf("\n enter string");
scanf("%s",str);
printf("\n enter character");
scanf("%s",ch);
for(i=0;i[str]!='\0';i++)
{
if(str[i]==ch)
{
occ++;
}
}
printf("\n occurance of %c in %s is %d",ch str occ);
getch();
}
| Is This Answer Correct ? | 25 Yes | 66 No |
Post New Answer View All Answers
Define macros.
Can include files be nested? How many levels deep can include files be nested?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
Why is c still so popular?
Why ca not I do something like this?
How will you divide two numbers in a MACRO?
Write a program to find factorial of a number using recursive function.
What are the back slash character constants or escape sequence charactersavailable in c?
What is strcpy() function?
What is meant by 'bit masking'?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
How can my program discover the complete pathname to the executable from which it was invoked?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
write a c program to find the sum of five entered numbers using an array named number
What is the Purpose of 'extern' keyword in a function declaration?