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
How can I trap or ignore keyboard interrupts like control-c?
Is c language still used?
i have a written test for microland please give me test pattern
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Explain what is the advantage of a random access file?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
What is pass by reference in functions?
What is c language used for?
Is the exit() function same as the return statement? Explain.
What is a void pointer? When is a void pointer used?
How to declare pointer variables?
When should the register modifier be used? Does it really help?
Explain heap and queue.
How can I remove the trailing spaces from a string?
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above