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 a keyword?
What is the default value of local and global variables in c?
regarding pointers concept
What is storage class?
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.
What is multidimensional arrays
What are the advantages of Macro over function?
Why is event driven programming or procedural programming, better within specific scenario?
What are formal parameters?
Is printf a keyword?
Why is c faster?
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?
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?
what value is returned to operating system after program execution?
What is && in c programming?