C Programming
Computer Programming

Program in C to find array of integers containing duplicate elements



Write a Program in c to find array of integers containing duplicate elements

\* C Program to to find array of integers containing duplicate elements *\

# include < stdio.h >
int   main( )
{

int   a[20], i, j, n, dub=0, dubn=0  ;
printf(" Enter the Numbers of element: ") ;
scanf("%d ", & n) ;
printf("\n Enter the elements : \n") ;
for (  i = 1 ; i < = n ; i++ )
scanf("%d ", & a[i]) ;

for (  i = 1 ; i < = n ; i++ )
{

dub = 0 ;
for (  j = i ; j < = n ; j++ )
{

if ( a[j] <= a[i]  )
{

dub = dub + 1 ;
}

}
if ( dub > 1 )
{

printf(" \n %d is a dublicate element.", a[i]) ;
dubn = 1 ;

}

}
if ( dubn == 0 )
printf("\n There is no dublicate element. ") ;
return ( 0 ) ;

}

Output of Program :

Output of Program in C to find array of integers containing duplicate elements