Skip to content

Commit 5229a41

Browse files
authored
Create 4.c
1 parent 74aaf88 commit 5229a41

File tree

1 file changed

+30
-0
lines changed
  • Special Programs

1 file changed

+30
-0
lines changed

Special Programs/4.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//Write a C function to find the frequency of a particular number in a list of integers, passed by using pointer.
2+
3+
#include<stdio.h>
4+
int frequency(int *f,int n,int num)
5+
{
6+
int i,freq=0;
7+
for(i=0;i<n;i++)
8+
{
9+
if(*(f+i)==num)
10+
{
11+
freq++;
12+
}
13+
}
14+
return freq;
15+
}
16+
void main()
17+
{
18+
int n,num,i,array[100],freq;
19+
printf("Enter the length of array ");
20+
scanf("%d",&n);
21+
printf("Enter %d elements ",n);
22+
for(i=0;i<n;i++)
23+
{
24+
scanf("%d",&array[i]);
25+
}
26+
printf("Enter the number whose frequency is to be checked ");
27+
scanf("%d",&num);
28+
freq=frequency(array,n,num);
29+
printf("Frequency of the number %d is = %d\n",num,freq);
30+
}

0 commit comments

Comments
 (0)