Write a c program to accept n numbers from user store these number into an array count 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();
}

Comments