explain working of this code.. explain its each line
#include using namespace std;// Function to change all duplicate elements to -1void 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="" :="">"final> for(int k=0; k { cout<><">"> } N = N-count; cout<><"final value="" of="" n="" is="" :="">"final><>}// Driver Functionint main(){ int i,n ; cout<"enter array="" size:="" ";="" taking="" input="" for="" array="">"enter> cin>>n; int a[n]; cout<"enter elements="" in="" array="" :="" ";="" taking="" input="" for="" array="">"enter> for(i=0; i { cin>>a[i]; } eliminate_duplicates(a,n); return 0;}
// Driver Functionint main(){ int i,n ; cout<"enter array="" size:="" ";="" taking="" input="" for="" array="">"enter> cin>>n; int a[n]; cout<"enter elements="" in="" array="" :="" ";="" taking="" input="" for="" array="">"enter> for(i=0; i { cin>>a[i]; } eliminate_duplicates(a,n); return 0;}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here