A string of charaters were given. Find the highest
occurance of a character and display that character.
eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE
OUTPUT: E
Answer Posted / sreejesh1987
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
char str[20];
int max[20],x=1,high;
clrscr();
printf("Enter the string");
scanf("%s",str);//assas[s]iation
n=strlen(str);
for(i=0;i<n;i++)
max[i]=1;
for(i=0;i<n;i++)
{
for(j=0;j<i;j++)
if(strcmp(str[i],str[j])==0)
{
max[i]++;
if(max[i]>x)
{
x=max[i];
high=i;
}
}
}
printf("%c is occured %d times",str[high],x);
getch();
}
| Is This Answer Correct ? | 21 Yes | 1 No |
Post New Answer View All Answers
Performance Algorithm A performs 10n2 basic operations and algorithm B performs 300 lg n basic operations. For what value of n does algorithm B start to show its better performance?
i don't know about working of nested for loop can any one help me
write a program that reads a series of strings and prints only those strings begging with letter "b"
Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37
write a program using virtual function to find the transposing of a square matrix?
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
How to swap two ASCII numbers?
how to diplay a external image of output on winxp by using c & c++,
Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++
how to write a program that opens a file and display in reverse order?
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n
output for printf("printf");
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.