hopw to check how many duplicates in an array c
/**
* C program to count total number of duplicate elements in an array
*/
#include <stdio.h>
#define MAX_SIZE 100 // Maximum array size
int main()
{
int arr[MAX_SIZE];
int i, j, size, count = 0;
/* Input size of array */
printf("Enter size of the array : ");
scanf("%d", &size);
/* Input elements in array */
printf("Enter elements in array : ");
for(i=0; i<size; i++)
{
scanf("%d", &arr[i]);
}
/*
* Find all duplicate elements in array
*/
for(i=0; i<size; i++)
{
for(j=i+1; j<size; j++)
{
/* If duplicate found then increment count by 1 */
if(arr[i] == arr[j])
{
count++;
break;
}
}
}
printf("\nTotal number of duplicate elements found in array = %d", count);
return 0;
}
Also in C:
- How to Convert double to int in C
- change text color c
- how to make two arrays equal in c
- strdup c
- read file in C
- factorial of a given number in c
- if statement in c
- diamond dataset in r
- global and local variables in c
- clear screen c
- print long in c
- even odd c
- PS1 modified lags
- c unused parameter
- if statement shorthand c
- c \a
- command line coursera
- Multi Select with icons htm;
- c print hello world
- 1 212 32123 4321234 543212345 in c
- triangulo
- java.lang.SecurityException: Permission denied (missing INTERNET permission?)
- pow() c
- is animal crossing for kids