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 |
int n=1; while(1) { switch(n) { case 1:printf("a"); n++; continue; case 2:printf("b"); n++; continue; default : printf("c"); break; } break; }
What is && in c programming?
input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure
what is the output of the following program? main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }
What is the use of in c?
Define function ?Explain about arguments?
2 Answers Geometric Software, Infosys,
What is the best style for code layout in c?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?
write a program in reverse the string without using pointer,array,global variable declaration,lib fun only using a function?
What are inbuilt functions in c?
Write a code to generate a series where the next element is the sum of last k terms.
What is define c?