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 ”)
Answers were Sorted based on User's Feedback
Answer / ankur
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char str[40],ch;
int num;
cout<<"Entre a string :";
cin.getline(str,40);
cout<<"Entre a character :";
cin>>ch;
for(int i=0;i!='\0';++i)
{
if(str[i]==ch)
num=num+1;
}
cout<<num;
getch();
}
| Is This Answer Correct ? | 20 Yes | 74 No |
Answer / jyoti
#include<stdio.h>
#include<conio.h
#include<string.h>
void main()
{
char st[200],nw[20];
int i,j=0;
clrscr();
printf("enter string");
gets(st);
printf("enter new string");
gets(nw);
for(i=0;st[i]!='\0';i++)
{if (strcmp(nw,st)==0)
j=j++;
}}
getch();
}
| Is This Answer Correct ? | 68 Yes | 183 No |
Explain the bubble sort algorithm.
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
There are 3 baskets of fruits with worng lables,one basket has apple,another basket has orange,another has combination of apple and orange,what is the least way of interchange the lables.
15 Answers Cisco, Google, MBT,
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
Difference between data structure and data base.
7 Answers CTS, Value Labs, Zoho,
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
How to reverse alternate words in a given line of string For Eg: my name is narasimha output : my eman is ahmisaran
what is bitwise operator?
Will Macros support multiple arguments ?
Is null always equal to 0(zero)?
Is exit(status) truly equivalent to returning the same status from main?
How do we print only part of a string in c?