c program to count 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;
}#include <stdio.h>
int main(void) {
int i,j,count=0;
int a[10];
int size;
printf("enter the number of elements");
scanf("%d",&size);
for(i=0;i<size;i++)
{
printf("enter array elements");
scanf("%d",&a[i]);
}
for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if (a[i]==a[j])
{
count+=1;
break;
}
}
}
printf("duplicate elements\n");
printf("%d",count);
return 0;
}
Also in C:
- Title
- how to only show tenths place in c
- Category
- C
- Title
- sustituir un dígito por otro
- Category
- C
- Title
- how to globally initlailize a struct
- Category
- C
- Title
- kadane's algorithm
- Category
- C
- Title
- tmux how to kill all sessions
- Category
- C
- Title
- error: ‘istringstream’ is not a member of ‘std’
- Category
- C
- Title
- printf("%3d ",XX);
- Category
- C
- Title
- declare variable in c
- Category
- C
- Title
- factorial of a given number in c
- Category
- C
- Title
- c array
- Category
- C
- Title
- how to call the tkinter insert command from another class
- Category
- C
- Title
- typedef in c
- Category
- C
- Title
- use of matplotlib inline
- Category
- C
- Title
- windeployqt example
- Category
- C
- Title
- v
- Category
- C
- Title
- how to use ? in c
- Category
- C
- Title
- what is a long long int in c
- Category
- C
- Title
- command line coursera
- Category
- C
- Title
- azure storage emulator config
- Category
- C
- Title
- arduino digital input pins
- Category
- C
- Title
- docker logs follow
- Category
- C
- Title
- what is stdin in c
- Category
- C
- Title
- vbl share price
- Category
- C
- Title
- set timezone in debian terminal
- Category
- C
- Title
- append to list in c
- Category
- C
- Title
- strrev in c
- Category
- C
- Title
- program using if statement in c whether numnber is less eqaul to greater than 50
- Category
- C
- Title
- a enum data type in c
- Category
- C
- Title
- write array of char to file in c
- Category
- C
- Title
- command line arguments c
- Category
- C
- Title
- es fibo
- Category
- C
- Title
- arduino digital read
- Category
- C
- Title
- reverse function in c
- Category
- C
- Title
- potencia recursiva
- Category
- C
- Title
- debian install npm
- Category
- C
- Title
- c program to find the sum of given number using recursion
- Category
- C
- Title
- 233 pounds to inr
- Category
- C
- Title
- How to make a printf in c
- Category
- C
- Title
- qtableview get selected row
- Category
- C
- Title
- docker run port mapping
- Category
- C
- Title
- pasar a binario recursivo
- Category
- C
- Title
- div
- Category
- C
- Title
- piramide
- Category
- C
- Title
- what are the causes of memory leaks in c
- Category
- C
- Title
- c fill 2d array
- Category
- C
- Title
- how to put quotes inside string c
- Category
- C
- Title
- docker pull command
- Category
- C
- Title
- jock cranley
- Category
- C
- Title
- fibonacci in c
- Category
- C
- Title
- is c and c++ platform independent
- Category
- C
- Title
- how to pass an array value to a pthread in c
- Category
- C
- Title
- undefined symbols for architecture x86_64 in c
- Category
- C
- Title
- c float to int
- Category
- C
- Title
- c check if char is an operator
- Category
- C
- Title
- c program to count duplicates in an array
- Category
- C
- Title
- chat c socket tcp geeksforgeeks
- Category
- C
- Title
- where is my vimrc
- Category
- C
- Title
- sum of arrays
- Category
- C
- Title
- C why is is & nit used in scan f fr string
- Category
- C
- Title
- linux directory commands
- Category
- C
- Title
- fa fa-facebook
- Category
- C
- Title
- c value set to zero __memmove_avx_unaligned_erms
- Category
- C
- Title
- prime number
- Category
- C
- Title
- infinite loop using while
- Category
- C
- Title
- ‘uint64_t’ was not declared in this scope
- Category
- C
- Title
- how to print in c
- Category
- C
- Title
- select all file from date powershell
- Category
- C
- Title
- print variable c
- Category
- C
- Title
- strtok
- Category
- C
- Title
- c defined value sum
- Category
- C
- Title
- c matrix sintax
- Category
- C
- Title
- c isdigit function
- Category
- C
- Title
- can we write a program without main in c
- Category
- C
- Title
- #include<stdlib.h>
- Category
- C
- Title
- compare two chars c
- Category
- C
- Title
- inurl:fiu.edu math faculty
- Category
- C
- Title
- declaring a volatile in c
- Category
- C
- Title
- calculate max of three numbers using ternary operator in c
- Category
- C
- Title
- battlefield4u.com
- Category
- C
- Title
- read files in c
- Category
- C
- Title
- xamarin command listview button
- Category
- C
- Title
- c bit access union
- Category
- C
- Title
- diagonales
- Category
- C
- Title
- disable gnu++11 option
- Category
- C
- Title
- factors using recursion
- Category
- C
- Title
- how to do matrix multiplication in c
- Category
- C
- Title
- incompatible types when initializing type ‘float’ using type ‘point {aka struct point}’
- Category
- C
- Title
- c print array
- Category
- C
- Title
- a enum data type in c with loop
- Category
- C
- Title
- passing 2d array as parameter to function in c
- Category
- C
- Title
- arduino knn
- Category
- C
- Title
- multiplication in c
- Category
- C
- Title
- delete string function in c
- Category
- C
- Title
- powershell list big files
- Category
- C
- Title
- cantidad de digitos recursiva
- Category
- C
- Title
- switch case c
- Category
- C
- Title
- how to make a linked list in c
- Category
- C
- Title
- how to login to another user in powershell
- Category
- C
- Title
- stack implementation
- Category
- C
- Title
- Docker error Error response from daemon: conflict: unable to remove repository reference
- Category
- C