You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
746 B
C

/*
* C Program to Print all the Repeated Numbers with Frequency in an Array
*/
#include <stdio.h>
#include <malloc.h>
void duplicate(int array[], int num)
{
int *count = (int *)calloc(sizeof(int), (num - 2));
int i;
printf("duplicate elements present in the given array are ");
for (i = 0; i < num; i++)
{
if (count[array[i]] == 1)
printf(" %d ", array[i]);
else
count[array[i]]++;
}
}
int main()
{
int array[] = {5, 10, 10, 2, 1, 4, 2};
int array_freq = sizeof(array) / sizeof(array[0]);
duplicate(array, array_freq);
getchar();
return 0;
}
/*
duplicate elements present in the given array are 10 2