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 a keyword?

740


What is the default value of local and global variables in c?

557


regarding pointers concept

1567


What is storage class?

654


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1575






What is multidimensional arrays

624


What are the advantages of Macro over function?

1190


Why is event driven programming or procedural programming, better within specific scenario?

1949


What are formal parameters?

652


Is printf a keyword?

755


Why is c faster?

590


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

1584


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

657


what value is returned to operating system after program execution?

1599


What is && in c programming?

674