1.)how to find d most repeated word in a string?
string ="how do you do"??
output should be do



1.)how to find d most repeated word in a string? string ="how do you do"?? output should..

Answer / amit khurana

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char arr[10]={0},x[1000],y[10][100],i,j,k=1,count=0,a1;
int l,a,temp;
clrscr();
gets(x);
l=strlen(x);
for(i=0;i<=l;i++)
{
if(x[i]==' '&&count==0)
{
for(j=0;j<=i-1;j++)
y[0][j]=x[j];
y[0][j]='\0';
a=i+1;
count++;
}
else if(x[i]==' ')
{
for(a1=0,j=a;j<=i-1;j++,a1++)
y[k][a1]=x[j];
y[k][a1]='\0';
a=i+1;
k++;
}
else if(x[i]=='\0')
{
for(a1=0,j=a;j<=i-2;j++,a1++)
y[k][a1]=x[j];
y[k][a1]='\0';
a=i+1;
k++;
}
}
for(i=0;i<=k-2;i++)
{
for(j=i+1;j<=k-1;j++)
{
if(strcmp(y[i],y[j])==0)
arr[i]++;
}
}
temp=arr[0];
for(i=1;i<=9;i++)
if(temp<arr[i])
temp=arr[i];
for(i=0;i<=9;i++)
if(temp==arr[i])
break;
printf("maximum repeated string is %s",y[i]);
getch();
}

Is This Answer Correct ?    17 Yes 30 No

Post New Answer

More C Interview Questions

What is the difference between scanf and fscanf?

0 Answers  


What’s a signal? Explain what do I use signals for?

0 Answers  


What is Conio.h ?

2 Answers   TCS,


WHAT IS HEADER?

8 Answers   ProKarma, TCS,


How can I get the current date or time of day in a c program?

0 Answers  


i=10,j=20 j=i,j?(i,j)?i:j:j print i,j

1 Answers   CSC,


What is a macro?

0 Answers  


SRUCTURE PROGRAMMING

3 Answers   CTS, Wipro,


how to find the largest element of array without using relational operater?

6 Answers   Satyam, Wipro,


What is an lvalue in c?

0 Answers  


What is the g value paradox?

0 Answers  


What is variable declaration and definition in c?

0 Answers  


Categories