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
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
Explain c preprocessor?
State the difference between realloc and free.
Explain how do you convert strings to numbers in c?
How is actual parameter different from the formal parameter?
What is getche() function?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
What is the difference between array and pointer in c?
Do you have any idea about the use of "auto" keyword?
Why do we use pointer to pointer in c?
What are the 5 types of inheritance in c ++?
What are formal parameters?
What is c programing language?
Is c programming hard?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?