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
How can I sort more data than will fit in memory?
What is the -> in c?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
cavium networks written test pattern ..
What are variables and it what way is it different from constants?
What is the scope of static variables in c language?
Is c object oriented?
How can I remove the leading spaces from a string?
develop algorithms to add polynomials (i) in one variable
What is the full form of getch?
What is the use of getchar functions?
What is a header file?
What is the data segment that is followed by c?
What are disadvantages of C language.
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor