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 %d used for?
Explain what is the advantage of a random access file?
What is the use of bitwise operator?
How to declare pointer variables?
Why c is called procedure oriented language?
What is getch c?
Why is c faster?
Explain what is the benefit of using enum to declare a constant?
Explain how can type-insensitive macros be created?
Why is this loop always executing once?
What are the advantages of the functions?
how is the examination pattern?
Explain the bubble sort algorithm.
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
Is c is a low level language?