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


Please Help Members By Posting Answers For Below Questions

What is the scope of global variable in c?

549


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1491


What is C language ?

1522


What is break in c?

579


What is omp_num_threads?

572






Is null equal to 0 in sql?

644


What are the advantages of the functions?

600


What is a static function in c?

614


Does c have an equivalent to pascals with statement?

567


Can we increase size of array in c?

534


What is the benefit of using an enum rather than a #define constant?

651


Explain 'bus error'?

553


What is the difference between new and malloc functions?

572


What does s c mean on snapchat?

579


What is the newline escape sequence?

578