top of page
Frequently Asked C Language Interview Question & Answers
Write program to remove duplicate in an array ?
C program to remove duplicate programme:
#include <stdio.h>
int main()
{
int n, a[100], b[100], calc = 0, i, j;
printf("Enter no. of elements in array\n");
scanf("%d", &n);
printf("Enter %d integers\n", n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
for (i = 0; i<n; i++)
{
for (j = 0; j < calc; j++)
{
if(a[i] == b[j]) break;
}
if (j== calc)
{
b[count] = a[i]; calc++;
}
}
printf("Array obtained after removing duplicate elements:\n");
for (i = 0; i < calc; i++)
printf("%d\n", b[i]);
return 0;
}
bottom of page