I am trying to write a program that will input numbers in a array and then loop throught the array and look for dupes. The final output of the array should have the numbers in the array printed only once. And zero signals the end of the array and shouldn't be outputed. This is what I have so far can anyone show me my mistake.
Code:
#include <iostream> using namespace std; int main() { int scores[20]; //array of numbers int value; int dupe; int count; //prompt user for the list of numbers with zero being the end of the input. cout << "enter a list of numbers: "; for (int i=0; i < 20; i++){ cin >> value; if (value == 0) { break; } scores[i] = value; if (scores[i] == value) { dupe = 1; } } if (dupe != 1) { scores[count] = value; } count++; cout << value; }
Comment