Array:
Collection of different values having same data type is known as Array.
Example-
Array is 1 2 5 9 1 8 9 1
Occurance of 1 is 3
Occurance of 2 is 1
Occurance of 9 is 2
program-
#include< stdio.h>
int main()
{
int a[100],n,count=0,num,i;
printf("Number of elements in array ?n");
scanf("%d",&n);
//input in array
printf("Enter %d number in array\n",n);
for(i=0;i< n;i++)
scanf("%d",&a[i]);
printf("Enter number to search\n");
scanf("%d",&num);
//Find occurrence
for(i=0;i< n;i++)
{
if(num==a[i])
count++;
}
printf("Occurane of %d in array is %d",num,count);
}
Number of elements in array ?
6
Enter 6 number in array
1 3 2 1 2 3
Enter number to search
1
occurance of 1 in array is 2
Number of elements in array ?
6
Enter 6 number in array
1 3 2 1 2 3
Enter number to search
8
occurance of 8 in array is 0