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
When is a void pointer used?
Explain what is the difference between null and nul?
PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE
What are c preprocessors?
What is int main () in c?
What is wrong in this statement?
Is c call by value?
What are local static variables? How can you use them?
C language questions for civil engineering
What is malloc() function?
Write a progarm to find the length of string using switch case?
What is && in c programming?
What is s or c?
What are the advantages of using linked list for tree construction?
What is volatile variable in c with example?