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

Iam using Microsoft Visual Studio to create a system for mobile store I want to know how to calculate mobile price that the customer buy and how to reduce quantity from the data base that we have for mobile .And also how to calculate revnue for each mobile and revnue for the total mobile

2007


what are resources in case of Threads

2215


Find out the roles which gives access to all tables in SAP? Thanks in advance.

1984


5. How do you round the addition or subtraction of two numbers in assembler?

2164


When we use Windows authentication mode

1993


could you please tell me how to draw the calibration curve for HPLC {the software which we are using}?

1690


can we retrieve only integer/String type columns from a table,if yes how?

1876


Delta 5 weight scale not connect with oracle application what i can do?

2271


code for connection from windows forms to sql server

2176


What is diffrent between Method and and function in c#

1959


Write a program to find factorial of a number using functions

1647


how to display xisheet in list box in c# .net

2038


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

1937


Difference between delegates and Events?

2125


what are all the validation we need to perform in data stage?

2356