Program to find the highest repeated character in the string
This post is all about a c program which finds the highest repeated character from the given string and prints it with it's frequency. This program initially takes an input from the user and store it in a character array. Then it scans each and every character and stores the frequency of the characters and compares with the next character. Basically the program runs by two loops.
Screenshots[Demo]:
The Code:
Found Bugs, Feel free to report them !
Screenshots[Demo]:
Output showing various testcases
The Code:
#include<stdio.h>
#include<string.h>
int main()
{
char a[20]="",c;
int i,j,b=0,count=0;
printf("Enter The String: ");
gets(a);
for (i=0;i<=strlen(a)-1;i++)
{
for (j=i;j<=strlen(a)-1;j++)
{
if(a[i]==a[j])
{
count++;
}
}
if(b<=count)
{
c=a[i];
b=count;
}
count=0;
}
printf("The Maximum Repeated Charecter is %c, repeated %d times.",c,b);
return 0;
}
Found Bugs, Feel free to report them !

Comments
Post a Comment