C Program to Count All Duplicate Elements in an Array

In this program, you will take five numbers from the user and finding the total number of the duplicate elements present in an array.

Program to Count total Duplicate Elements in an Array

#include<stdio.h>
int main()
{
   int a[5],i,j,c=0;
   printf("enter the array of five element:");
   for(i=0;i<5;i++)
 	scanf("%d",&a[i]);
   for(i=0;i<5;i++)
   {
     for(j=i+1;j<5;j++)
     {
        if(a[i]==a[j])
   	{ c++; }
	break;
      }
   }
   printf("total dublicate element are %d",c);
   return 0;
}

output

enter the array of five element:1 1 1 1 1
total dublicate element are 4