Write program to remove duplicate in an array ?

devquora
devquora

Posted On: Feb 22, 2018

 

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;}

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    C Programming Interview Questions

    What are static variables in C ?

    C defines another class of variables called static variables. Static variables are of two types:Static variables tha..

    C Programming Interview Questions

    What is a scope resolution operator in C ?

    The scope resolution operator (::) is useful in C programming when both global and local variables have the same name,..

    C Programming Interview Questions

    What is register variable in C language ?

    C language allows the use of the prefix register in primitive variable declarations. Such variables are called register..