To find non-duplicate numbers in an array

This program can print all non-duplicate numbers present in an array.
Logic:
- Check the duplicate element in the array.
- Then eliminate the duplicate elements from the array.
- Remaining elements are non-duplicate elements.
Algorithm:
- Get the input array from the user.
- Then check the current element with all other elements.
- If the array element reaches the last index and all elements are not equal it non-duplicate element.
- Repeat step 2 to step 4 until it reaches the last element.
Program:
[code lang=”c”]
#include<stdio.h>
void main()
{
int a[100],i,j,n;
clrscr();
printf("enter the length of array");
scanf("%d",&n);
printf("enter the elements into array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Non duplicate elements are:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i!=j&&a[i]==a[j])//checks with all elements in array
{
break;//if their values are equal it exits from inner loop
}
if(j==n-1)//prints only the values not equal and also it reaches last index
{
printf("%3d",a[i]);
}
}
}
getch();
}
[/code]