Duplicate Removal

Description:

Program to Delete duplicate elements from an array Test Case 1 Input (stdin) 5 1 3 4 5 3 Expected Output 1 3 4 5 Test Case 2 Input (stdin) 3 1 3 3 Expected Output 1 3

Program :

#include <stdio.h>
int main()
{
int arr[20], i, j, k, size;
 
   
   scanf("%d", &size);
 
   
   for (i = 0; i < size; i++)
      scanf("%d", &arr[i]);
 
   printf("\n");
   for (i = 0; i < size; i++) {
      for (j = i + 1; j < size;) {
         if (arr[j] == arr[i]) {
            for (k = j; k < size; k++) {
               arr[k] = arr[k + 1];
            }
            size--;
         } else
            j++;
      }
   }
 
   for (i = 0; i < size; i++) {
      printf("%d ", arr[i]);
   }
 return 0;
}