Write a ‘C’ Program to accept ‘n’ numbers from user, store these numbers into an array and count the number of occurrence of each number.


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,cnt,a[10],temp,no;
clrscr();
printf("\nenter the limit = ");
scanf("%d",&n);
printf("\n Enter the %d number",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<n;i=j)
{
no=a[i];
cnt=1;
for(j=i+1;j<n;j++)
{
if(a[j]!=no)
break;
else
cnt++;
}
printf("\n%d no occurs %d times\n ",no,cnt);
}
getch();
}
/* output

enter the limit = 5

 Enter the 5 number
11
56
89
22
11

11 no occurs 2 times
22 no occurs 1 times
56 no occurs 1 times
89 no occurs 1 times */