 # Unique elements of array | Duplicate Total of Array

Hi Guys. Welcome you all. Here I came with an interesting tutorial. We are going to find the Unique elements of an array. Also, we will find the duplicate total of the elements of an array.  Today we are going to write a program to check whether a given number is a perfect-number with a c program.

Before the start our tutorial I have to do a little request. If you haven’t liked our Facebook Page yet, please like it to support us. (FB Page: BMaxx Edu). OK, let’s move to our stuff how to check a given Number is a Perfect Number

### Unique Elements

In this case, we count the frequency of each element and sort out the elements, which have the frequency value 01.

```int main()
{
int size, i, j, count;
printf("Unique Elements \n");
printf("Enter size of array: ");
scanf("%d", &size);
int arr[size], freq[size];
printf("\n \n");

for(i=0; i<size; i++)
{
printf("Enter elements to array: ");
scanf("%d", &arr[i]);
}
for(i=0; i<size; i++)
{
count = 1;
for(j=i+1; j<size; j++)
{
if(arr[i]==arr[j])
{
count++;
freq[j]=0;
}
}
if(freq[i] != 0)
{
freq[i]=count;
}
}

printf("\nUnique elements in the array are: ");
for(i=0; i<size; i++)
{
if(freq[i] == 1)
{
printf("%d  ", arr[i]);
}
}
return 0;
}
```

### Count the duplicate total

In this case, we count the frequency of each number. Then we sort out the duplicated numbers and get the total of their counts. You can use the following programming code to get the answer.

```int main()
{
int size, i, j, tcount, count=0;
printf("Duplicate Total \n");
printf("Max Array Size is 100 \n");
printf("Enter size of array: ");
scanf("%d", &size);
int arr[size];
printf("\n \n");

for(i=0; i<size; i++)
{
printf("Enter elements to array: ");
scanf("%d", &arr[i]);
}

for (i=0; i<size; i++)
{
tcount=0;
for (j=i+1; j<size; j++)
{
if(arr[i]== arr[j])
{
tcount+=1;
}
}
if (tcount!=0)
count+=1;
}

printf("Total Number of duplicates : %d",count);
return 0;
}
```
Bonomi Tharinda is the Developer of the BMaxx Blog. He is a skilled web developer and graphic designer. In addition, he is an undergraduate student of a representative University in Sri Lanka. He is working as a tutor of an institute and as a part-time blogger, he will help you all to make your problems solved.Here are his social accounts and you can follow him through them.