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
What is the scope of global variable in c?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
What is C language ?
What is break in c?
What is omp_num_threads?
Is null equal to 0 in sql?
What are the advantages of the functions?
What is a static function in c?
Does c have an equivalent to pascals with statement?
Can we increase size of array in c?
What is the benefit of using an enum rather than a #define constant?
Explain 'bus error'?
What is the difference between new and malloc functions?
What does s c mean on snapchat?
What is the newline escape sequence?