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 / vignesh1988i

#include<stdio.h>
#include<conio. h>
void main()
{
char str[100],*ptr[50],a;
int count=0,count2=0,count,k=0;
printf("enter the string :");
fflush(stdin);
gets(str);
for(int i=0;str[i]!='\0';)
{
count=0;

if(str[i]==' ')
{
i++;
contine;
}
for(int j=i;str[j]!='\0';j++)
{
if(str[j]==' ')
continue;
if(str[i]==str[j])
count++;
}
if(count>count1)
{
count1=count;
a=str[i];
}
ptr[k]=&str[i];
i++;
count2++;
for(j=0;j<count2;j++)
{
if(str[i]==*(*(ptr+j)))
{
i++;
j=-1;
}
}
}
printf("the occurance of the char. is %c , count is %d times",a,count1);
getch();
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c is a low level language?

570


What is an lvalue?

638


write a program to create a sparse matrix using dynamic memory allocation.

4377


Is it better to use a macro or a function?

660


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

613






How do I create a directory? How do I remove a directory (and its contents)?

612


What are the two forms of #include directive?

649


Do pointers take up memory?

670


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2587


How can I manipulate strings of multibyte characters?

643


What is the g value paradox?

654


What is the difference between malloc() and calloc() function in c language?

612


What are different types of operators?

604


What is the size of empty structure in c?

601


When can a far pointer be used?

598