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 an endless loop?
What is the heap in c?
What is the process of writing the null pointer?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
How to define structures? ·
What does return 1 means in c?
Can we use any name in place of argv and argc as command line arguments?
What is the purpose of clrscr () printf () and getch ()?
write a program to copy the string using switch case?
What are actual arguments?
What are global variables and how do you declare them?
How do you sort filenames in a directory?
What is a function in c?
In a header file whether functions are declared or defined?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples