Computer Science, asked by abdulkhanabdul8249, 10 months ago

Write a program in c to calculate number of duplicate entries in array

Answers

Answered by Anonymous
0

Answer:

printf("\n Please Enter Number of elements in an array : "); scanf("%d", &Size); Below For loop will help to iterate each and every cell present in the arr[5] array. Condition inside the for loops (i < Size) will ensure the compiler, not to exceed the array limit. The condition (0 < 5) is True.

Answered by mdrushdalamin1
1

Answer:

/* C Program to Count Total Duplicate Elements in an Array */

 

#include <stdio.h>

 

int main()

{

int arr[10], i, j, Size, Count = 0;

 

printf("\n Please Enter Number of elements in an array  :   ");

scanf("%d", &Size);

 

printf("\n Please Enter %d elements of an Array  :  ", Size);

for (i = 0; i < Size; i++)

{

    scanf("%d", &arr[i]);

   }      

 

for (i = 0; i < Size; i++)

{

 for(j = i + 1; j < Size; j++)

 {

     if(arr[i] == arr[j])

     {

      Count++;

   break;

  }

 }

}

 printf("\n Total Number of Duplicate Elements in this Array  =  %d ", Count);

     

 return 0;

}

Similar questions