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 |
fn f(x) { if(x<=0) return; else f(x-1)+x; }
Write a program that will read the input of any number of digits n in a row of shafh showing the breakdown of the printing and printing figures by the recursive function.
What are the advantages of using Unions?
Write a program to swap two numbers without using the third variable?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
who is the father of c
Who is the main contributor in designing the c language after dennis ritchie?
int main() { int x = (2,3,4); int y = 9,10,11; printf("%d %d",x,y); } what would be the output?
what is output of the following statetment?Printf(“%x”, -1<<4); ?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } after calling swap ,what are yhe values x&y?