Write a C program to count frequency of digits in a given number
#include<stdio.h>
int freq(int num,int m)
{
int n,c=0;
while(num>0)
{
n=num%10;
if(n==m)
c=c+1;
num=num/10;
}
return c;
}
int main ()
{
int f,n,m;
printf("enter the number = ");
scanf("%d",&n);
printf("enter the number to check frequency = ");
scanf("%d",&m);
f=freq(n,m);
printf("\n frequency of %d in the given number = %d",m,f);
return 0;
}
OUTPUT :
Post a Comment
0 Comments