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 #define size in c?

1122


What do you mean by dynamic memory allocation in c?

1053


What does emoji p mean?

1047


What is the use of ?

996


What is bubble sort technique in c?

934


how to find anagram without using string functions using only loops in c programming

3137


Write the Program to reverse a string using pointers.

971


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

1072


Explain data types & how many data types supported by c?

1027


What are the string functions? List some string functions available in c.

950


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

1206


Describe the order of precedence with regards to operators in C.

1006


What is bash c?

961


Is c is a low level language?

1070


Explain how can you restore a redirected standard stream?

1033