Write a c program to take input elements in an array from the user and count the total duplicate element present in an array
#include<stdio.h>
int main()
{
int a[20],i,j,count=0,n;
printf("enter the size of array:");
scanf("%d",&n);
printf("enter the array element:");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
/* if duplicate found increment count by 1 */
if(a[i]==a[j])
{
/* don't count next duplicate of current element */
count++;
break;
}
}
}
printf("\ntotal dublicate element are: %d",count);
return 0;
}
enter the size of array:5 enter the array element:1 1 1 2 1 total dublicate element are: 3