Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is an endless loop?

1251


What is the heap in c?

1049


What is the process of writing the null pointer?

1002


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

1043


‎How to define structures? · ‎

1043


What does return 1 means in c?

1035


Can we use any name in place of argv and argc as command line arguments?

1045


What is the purpose of clrscr () printf () and getch ()?

1038


write a program to copy the string using switch case?

2865


What are actual arguments?

1065


What are global variables and how do you declare them?

1039


How do you sort filenames in a directory?

1135


What is a function in c?

1517


In a header file whether functions are declared or defined?

1096


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

2165