explain working of this code.. explain its each line #include using namespace std; // Function to change all duplicate elements to -1 void eliminate_duplicates(int arr[] , int N) { int count=0, i, j;...



explain working of this code.. explain its each line


#include
using namespace std;

// Function to change all duplicate elements to -1
void eliminate_duplicates(int arr[] , int N)
{
    int count=0, i, j;
    for(i=0; i
    {
         if(arr[i]!=-1)
  {
      for(j=i+1; j
            {
            if(arr[i]==arr[j])
             {
          count++;
          arr[j]=-1;
         }
        }
   }
    }

    // Printing results
    cout<><"final state="" of="" array="" is="" :="">
    for(int k=0; k
    {
        cout<><">
    }
    N = N-count;
    cout<><"final value="" of="" n="" is="" :=""><>
}


// Driver Function
int main()
{
    int i,n ;
   cout<"enter array="" size:="" ";="" taking="" input="" for="" array="">
   cin>>n;
    int a[n];
    cout<"enter elements="" in="" array="" :="" ";="" taking="" input="" for="" array="">
    for(i=0; i
    {
        cin>>a[i];
    }
    eliminate_duplicates(a,n);
    return 0;
}



Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here