#include<stdio.h>
int main()
{
int array[100],n,i,j;
int Number,max=0,count=0;
printf("Please Enter Array Size: ");
scanf("%d",&n);
printf("Array Element: ");
for(i=0; i<n; i++)
{
scanf("%d",&array[i]);
}
for(i=0; i<n; i++)
{
count=0;
for(j=0; j<n; j++)
{
if(array[i]==array[j]) ///find total Occurrences
{
count++;
}
}
if(count>max)
{
max = count;
Number = array[i];
}
}
printf("
Number: %d Total Occurrences: %d
",Number,max);
return 0;
}
Output
Please Enter Array Size: 5
Array Element: 1 5 1 8 1
Number: 1 Total Occurrences: 3
Add your comment