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



1. Write a C program to count the number of occurrence of a specific word in the given strings. ..

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

1. Write a C program to count the number of occurrence of a specific word in the given strings. ..

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

Post New Answer

More C Interview Questions

for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????

7 Answers  


write a c program to find biggest of 3 number without relational operator?

12 Answers   TCS, Wipro,


Explain how do you search data in a data file using random access method?

0 Answers  


Write a C program to count the number of email on text

0 Answers  


how to TOGGLE Nth bit of variable in a MACRO

1 Answers   NDS,






What is the o/p of the follow pgm? #include<stdio.h> main() { char char_arr[5]=”ORACL”; char c=’E’; prinf(“%s\n”,strcat(char_arr,c)); } a:oracle b. oracl c.e d.none

2 Answers   Oracle,


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

0 Answers  


What is the process to generate random numbers in c programming language?

0 Answers  


What is header file in c?

0 Answers  


Program to find the sum of digits of a given number until the sum becomes a single digit

8 Answers   InterGraph,


Describe how arrays can be passed to a user defined function

0 Answers  


Where are some collections of useful code fragments and examples?

0 Answers   Celstream,


Categories