write a program to find the frequency of a number

Answer Posted / pratik roy

#include<stdio.h>
#include<conio.h>

void freq(int ,int ,int );

int main()
{
int a,key,count,i;
printf("Enter the elements\n");
scanf("%d",&a);
printf("Enter the element whose frequency is to be determined\n");
scanf("%d",&key);
freq(a,key,0);
getch();
return 0;
}

void freq(int num,int key,int count)
{
int samkey,i;
i=num/10;
if(i!=0)
{
samkey = num%10;
if(samkey == key ) {count++; freq(num,key,count);}
else
{
num=num/10;
freq(num,key,count);
}
}
printf("%d",count);
}

Is This Answer Correct ?    4 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c standard library?

687


Explain the ternary tree?

593


When would you use a pointer to a function?

580


When should you use a type cast?

583


find out largest elemant of diagonalmatrix

1643






What is use of #include in c?

588


What is the most efficient way to store flag values?

678


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1646


Is javascript based on c?

588


What does it mean when the linker says that _end is undefined?

621


Why is sprintf unsafe?

612


What does c mean before a date?

583


What is sizeof c?

598


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

580


What is strcpy() function?

650