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
Explain is it better to bitshift a value than to multiply by 2?
What is default value of global variable in c?
Why clrscr is used after variable declaration?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
In which layer of the network datastructure format change is done
What is a stream in c programming?
In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.
Is it possible to initialize a variable at the time it was declared?
What is difference between array and structure in c?
What is the difference between near, far and huge pointers?
What is ## preprocessor operator in c?
Is c object oriented?
What is getch?
Write a code to generate a series where the next element is the sum of last k terms.
How is a null pointer different from a dangling pointer?