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
difference between Low, Middle, High Level languages in c ?
Is it better to use malloc() or calloc()?
Explain what is the difference between a string and an array?
How do you view the path?
what type of questions arrive in interview over c programming?
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
List the difference between a While & Do While loops?
What is meant by type specifiers?
What is #line used for?
How can I implement sets or arrays of bits?
What does struct node * mean?
How can I copy just a portion of a string?
What is the scope of global variable in c?
What is dangling pointer in c?
Which are low level languages?