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...

A string of charaters were given. Find the highest
occurance of a character and display that character.
eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE

Answer Posted / aman bhullar

#include<string.h>
#include<stdio.h>


char HighestCharCount(char* str)
{

int length = strlen(str);
if (length == 0)
return ' ';
if (length == 1)
return str[0];

int indexOfHighest = -1;
int highestCounter = 0;
int i, j ,current = 0;
char test;
for ( i=0; i < length; ++i)
{
test = str[i];

for (j=i+1; j < length ; ++j)
{
if (str[j] == test)
{
current++;
}

if (current > highestCounter)
{
highestCounter = current;
indexOfHighest = i;
}
}
}
return str[indexOfHighest];
}

void main ( )
{
char a[] = "AEGBCNAvNEETGUPTAEDAGPE";
char res;
res = HighestCharCount(a);
printf("\n %c ", res);

}

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which method protects back button to retrieve old value from previous page in Struts.

1828


Display names and numbers of employees who have 5 years or more experience and  salary less than Rs.15000 using array of structures (name, number, experience and  salary)

4707


suppose we have ten members of a physical file but we want the output of last 5 members only.how to achieve that?

2033


what is log files in qtp what is use

1988


i am exeprienced person what is selection process

1584


which book we learned this mantis? how many version are realsed this mantis upto now?

1907


Is buffer size and file block size is similar? If similar,at which case it will be same size?

2147


what is difference between input parameter and output parameter.

4756


Always use scope terminator like End-If with IF, End- Evaluate with Evaluate statement.Can somebody explain me the detail logical explanation?

1949


When we have two versions of the dot net installed how does the compiler know which version of DLL it has to select to an application.

1870


write the a cl program with the following specification A. Accept 2 parameters-date and date type B. if date type is J then convert date to *MDY format C. if date type is M convert date to *JUL format 4.send a program message with the value of converted date Please explain for each with coding?

2596


what is web configuration file

2022


could u please also write an example of a code that involves instances from an abstract class just as u did for interfaces because u said it could also work which i really doubt. thanks

2067


Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.

1199


Code for display the images from drive using vb 6.0?

5139