write a program to display the frequency of each element in
a given array in c language
Answer / gaurav gangopadhyay
#include<stdio.h>
#include<conio.h>
void main()
{
char ch[10],stk[10];
int i=0;frq[10],b=-1,k,j;
printf("Enter string:");
gets(ch);
while(ch[i]!='\0')
{
if(b==-1)
{
b++;
stk[b]=ch[i];
frq[b]=frq[b]+1;
}
else
{
k=0;
for(j=0;j<=b;j++)
{
if(stk[j]==ch[i])
{
frq[j]=frq[j]+1;
k=1;
break;
}
}
if(k==0)
{
b++;
stk[b]=ch[i];
frq[b]=frq[b]+1;
}
}
i++;
}
for(i=0;i<=b;i++)
printf("\nNo of %c=%d",stk[i],frq[i]);
getch();
}
| Is This Answer Correct ? | 4 Yes | 12 No |
What are the loops in c?
WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE . Example: Enter the numbers :3 * * * * * * * *
what is ans for this scanf(%%d",c);
for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????
What are the differences between Structures and Arrays?
What are operators in c?
List some applications of c programming language?
with out using main how to execute the program?
if a person is buying coconuts of Rs10,and then sell that coconuts of Rs9,with the loss of one rupee.After that the person became a millaniore.how?
what is the difference between structure and union?
Can you pass an entire structure to functions?
how to implement stack operation using singly linked list