C program to find the element repeating maximum times in an array.

#include<stdio.h>
#include<stdlib.h>

int main() 
{
  int * array;
  int arraySize, i, j, max = 0, count = 1, element=0;
  
  /* Taking the size of an array as user input*/
  printf("Enter the size:");
  scanf("%d", & arraySize);
  
  /*Dynamically allocationg the memory for the array*/
  array = (int * ) malloc(arraySize * sizeof(int));
  printf("\n Enter the elements:");
  
  /*Taking the values of array as user input*/
  for (i = 0; i < arraySize; i++)
    scanf("%d", & array[i]);
    
  /*storing the value of first element in the num variable*/    
  element = array[0];
  
  
  for (i = 0; i < arraySize; i++) 
  {
    count=1;
    for (j = i + 1; j < arraySize; j++) 
    {
      if (array[i] == '*')
        break;
        
      if (array[i] == array[j]) 
      {
        count++;
        array[j] = '*';
      }
    }
    if (count > max) 
    {
      max = count;
      element = array[i];
    }
  }
  
  
  /*printing the element accoured maximum times*/
  printf("\n element repeating maximum times =%d", element);
  return 0;
}

Output:

Enter the size:10

 Enter the elements in an array:34 5 76 12 89 76 12 89 76 12 76

 element repeating maximum times =76



Above, program is to find the element which is occuring maximum times in an array.