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 #define size in c?
What do you mean by dynamic memory allocation in c?
What does emoji p mean?
What is the use of ?
What is bubble sort technique in c?
how to find anagram without using string functions using only loops in c programming
Write the Program to reverse a string using pointers.
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
Explain data types & how many data types supported by c?
What are the string functions? List some string functions available in c.
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
Describe the order of precedence with regards to operators in C.
What is bash c?
Is c is a low level language?
Explain how can you restore a redirected standard stream?