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
Definition of priority queue was given. We have to implement the priority queue using array of pointers with the priorities given in the range 1..n. The array could be accessed using the variable top. The list corresponding to the array elements contains the items having the priority as the array index. Adding an item would require changing the value of top if it has higher priority than top. Extracting an item would require deleting the first element from the corresponding queue. The following class was given: class PriorityQueue { int *Data[100]; int top; public: void put(int item, int priority); // inserts the item with the given priority. int get(int priority); // extract the element with the given priority. int count(); // returns the total elements in the priority queue. int isEmpty(); // check whether the priority queue is empty or not. }; We had to implement all these class functions.
output for printf("printf");
Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.
i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.
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
write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150
create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file
write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
Code for Method of Handling Factorials of Any Size?
solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)
How to swap two ASCII numbers?
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L