program to find which character is occured more times in a
string and how many times it has occured? for example in
the sentence "i love india" the output should be i & 3.
Answer Posted / venkatesh sabinkar
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char ch[30],t,i1;
int i,j,max=1,n=1;
clrscr();
printf("enter the sentence\n");
gets(ch);
for(i=0;i<strlen(ch);i++)
{
for(j=i+1;j<strlen(ch);j++)
{
if(ch[i]>ch[j])
{
t=ch[i];
ch[i]=ch[j];
ch[j]=t;
}
}
}
printf("\n%s",ch);
for(i=0;i<strlen(ch);i++)
{
if(ch[i]==ch[i+1])
{
n+=1;
}
if( max<n)
{
max=n;
i1=ch[i];
}
}
printf("\n%c %d",i1,max);
getch();
}
| Is This Answer Correct ? | 7 Yes | 3 No |
Post New Answer View All Answers
What is identifiers in c with examples?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
How many header files are in c?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
Explain bitwise shift operators?
When should a far pointer be used?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
How to draw the flowchart for structure programs?
Explain what is the heap?
How can I split up a string into whitespace-separated fields?
what is the significance of static storage class specifier?
Write a program that accept anumber in words
What is a protocol in c?
What is merge sort in c?
write a c program to calculate sum of digits till it reduces to a single digit using recursion