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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c programming hard?

576


Explain the array representation of a binary tree in C.

728


What is a memory leak? How to avoid it?

576


What are shell structures used for?

600


Is c procedural or object oriented?

580






program for reversing a selected line word by word when multiple lines are given without using strrev

1947


What is static memory allocation? Explain

632


What is a macro in c preprocessor?

628


What is the difference between local variable and global variable in c?

691


List the difference between a While & Do While loops?

639


Write a program to print numbers from 1 to 100 without using loop in c?

640


What are terms in math?

594


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

654


How can I implement sets or arrays of bits?

607


What are the 5 elements of structure?

566