#include<stdio.h>
int main ()
{ int a[20], i, j, k, size;
printf("Number of elements in an array:");
scanf ("%d",&size);
printf ("\nEnter %d elements of an array:\n",size);
for(i=0;i<size;i++)
{ scanf ("%d",&a[i]);
}
for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{ if(a[i]==a[j])
{ for (k=j; k<size-1;k++)
{ a[k]=a[k+1];
} size--;
j--;
}
}
}
printf ("Array elements after deletion of the duplicate elements:\n");
for(i=0;i<size;i++)
{ printf ("%d\n",a[i]);
}
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Number of elements in an array:5
Enter 5 elements of an array:
1
1
2
2
3
Array elements after deletion of the duplicate elements:
1
2
3