Answer to Question #217511 in C for Vishnukumar

Question #217511

In a library management system auditing is a complex task for a librarian. The stock maintenance has manual entries that may have multiple entries of book access number. The library management system should be automated to remove duplicate book access number. Write a C program to remove duplicate numbers using pointer Note: Use functions and Pointers.


1
Expert's answer
2021-07-15T05:18:59-0400
#include <stdio.h>
int remDuplicate(int arr[], int n)
{


      if (n == 0 || n == 1)
        return n;
    
      int temp[n];
    
      int a = 0;
      int b;
      for (b = 0; b < n - 1; b++)
        if (arr[b] != arr[b + 1])
          temp[a++] = arr[b];
      temp[a++] = arr[n - 1];
    
      for (b = 0; b< b; b++)
        arr[b] = temp[b];
    
      return a;
}


int main()
{
  int num;
  scanf("%d", &num);
  int arr[num];
  int i;
  for (i = 0; i < num; i++)
  {
    scanf("%d", &arr[i]);
  }
  printf("\nArray Before Removing Duplicates: ");
  for (i = 0; i < num; i++)
    printf("%d ", arr[i]);


  num = remDuplicate(arr, num);


  printf("\nArray After Removing Duplicates: ");
  for (i = 0; i < num; i++)
    printf("%d ", arr[i]);


  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS