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

Write a c pgm for leap year

11 Answers   College School Exams Tests, IBM, TCS,


DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?

2 Answers   Wipro,


Why main is not a keyword in c?

0 Answers  


what is a function method?give example?

0 Answers  


Define the scope of static variables.

0 Answers  






Explain built-in function?

0 Answers  


What is binary tree in c?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

5 Answers   TCS, Vimukti Technologies,


What 'lex' does?

0 Answers   Tech Mahindra,


write a function that accepts an integer/char array and an search item.If the search item is there in the array return position of array and value else return -1.without using other array,without sorting,not to use more than one loop?

3 Answers   Mind Tree,


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

0 Answers   TCS,


1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(ā€œ%dā€,x); --x; } }

7 Answers   CSC,


Categories