program to find which character is occured more times in a
string and how many times it has occured? for example in
the sentence "i love india" the output should be i & 3.

Answer Posted / venkatesh sabinkar

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char ch[30],t,i1;
int i,j,max=1,n=1;
clrscr();
printf("enter the sentence\n");
gets(ch);
for(i=0;i<strlen(ch);i++)
{
for(j=i+1;j<strlen(ch);j++)
{
if(ch[i]>ch[j])
{
t=ch[i];
ch[i]=ch[j];
ch[j]=t;
}
}
}
printf("\n%s",ch);
for(i=0;i<strlen(ch);i++)
{
if(ch[i]==ch[i+1])
{
n+=1;
}
if( max<n)
{
max=n;
i1=ch[i];
}

}
printf("\n%c %d",i1,max);
getch();
}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I sort more data than will fit in memory?

632


What is the -> in c?

589


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1534


cavium networks written test pattern ..

3600


What are variables and it what way is it different from constants?

793






What is the scope of static variables in c language?

634


Is c object oriented?

544


How can I remove the leading spaces from a string?

638


develop algorithms to add polynomials (i) in one variable

1747


What is the full form of getch?

587


What is the use of getchar functions?

680


What is a header file?

640


What is the data segment that is followed by c?

617


What are disadvantages of C language.

652


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

626