I'm trying to find and print the duplicate values in from a list of 10 integers, and I already have this part for the C++ program figured to find it.
#include <iostream>
using namespace std;
Program Main
int main() //Function Main
int array[10], out[10];
cout << "The following numbers appear multiple times: ";
for (int i = 0; i < 10; i++)
if (*(out + i) != 1)
cout << *(out + i) << " ";
cout << "\n";
system("pause");
return 0;
Function to find duplicates
int* getDuplicateValues(int array[], int out[], int size)//Finds values that were used more than once in the program
for (int i = 0; i < 10; i++)
out[i] = 1;
for (int i = 0; i < 10; i++)
{
int count = 1;
for (int j = i + 1; j < 10; j++)
{
if (array[i] == array[j])
count++;
}
if (count > 1)
out[i] = array[i];
count++;
}
return out;
The only problem is that it won't accept 1 as a duplicate value, and that is probably because of the coding on my part. And I'm relatively new to the coding process so all I need is a step in the right direction to forming the function correctly to find the duplicate values in the array. Please get back to me as soon as you can, preferably before Friday.