Question: /*function which takes the array as input and prints the duplicate values in that array using pointers.*/ void FindDuplicates(int p[],int N){ cout < < List

/*function which takes the array as input and prints the duplicate values in that array using pointers.*/ void FindDuplicates(int p[],int N){ cout<< "List of Duplicate values "; int count=0; int x, y;

for (x = 0; x < N; ++x) { for (y = x+1; y < N; ++y) { if (*(p + x) > *(p + y)) { int temp_save=*(p+x); *(p + x) =*(p + y); *(p + y)=temp_save; } } }

int i; for(i=0 ; i < N ;i++){ if(*(p +i) == *(p +i +1)) { if (*(p +i) == *(p +i -1)) { continue; }else{ cout<< " " << *(p +i) <

if(count==0){ cout<<"There are no duplicate values to be shown"<

The above function takes an array as an input and prints the duplicates in the array. It can only identify whether it is a duplicate or not. As an example if I enter 23,45,23,45,23 it will identify the duplicates as 23 and 45. I want to edit this function in order to print the times that the duplicate value appears as well. As an example the function should print

The duplicates are 23 and 45 . 23 is entered 3 times . 45 is entered 2 times.

Please edit this code to do so.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!