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 indirection?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What does typedef struct mean?
What is the difference between #include and #include 'file' ?
How are Structure passing and returning implemented by the complier?
What is the use of pointers in C?
Explain function?
What are global variables?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
write a program fibonacci series and palindrome program in c
Explain how can I convert a number to a string?
write a program to create a sparse matrix using dynamic memory allocation.
What is unary operator?
When should a type cast be used?
What is an identifier?