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 benefits of c language?
Differentiate abs() function from fabs() function.
What is a stream?
Can a program have two main functions?
All technical questions
What is the use of bit field?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
program for swapping two strings by using pointers in c language
What is the real time usage volatile?
Is c an object oriented programming language?
Explain a file operation in C with an example.