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

Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

0 Answers  


When should structures be passed by values or by references?

0 Answers   Adobe,


What are conditional operators in C?

0 Answers   Adobe,


How do I determine whether a character is numeric, alphabetic, and so on?

0 Answers  


void main() { int i=5; printf("%d",i++ + ++i); }

21 Answers   ME,






What are the different types of C instructions?

0 Answers   InterGraph,


What is the scope of an external variable in c?

0 Answers  


Is it possible to run using programming C for Java Application?

2 Answers   NIC,


IS STRUCTURES CAN BE USED WITHIN AN ARRAY?

7 Answers   Caritor,


what is the difference between arrays and linked list

26 Answers   MAHINDRA, Tech Mahindra, Wipro,


What type of function is main ()?

0 Answers  


4. main() { int c=- -2; printf("c=%d",c); }

0 Answers  


Categories