heya, i am making a program that prints out the unique numbers entered, for example if u enter 10 20 10 30 30 it would print : 10 20 30
this is my code
Code:#include <iostream> using std::cout; using std::endl; using std::cin; /* FUNCTION PROTOTYPES */ /****************************************************************************/ void print_Array (int [], int ); /****************************************************************************/ int main () { const int size = 10; int Readin_Array[size] = {0}; int Final_Array[size] = {0}; int temp = 0; int controller = 0; cout <<"Please enter 10 numbers.in range 10-100"<<endl; for (int x = 0; x<size; x++) { cout <<"please enter number "<< x+1 <<": "; cin >> temp; while (temp > 100 || temp < 10) { cout <<"the number must be between 10 and 100."<<endl; cin >> temp; } Readin_Array[x] = temp; } for (int x = 0; x<size; x++) { int Hold = Readin_Array[x]; int Count = 0; while (Count <= size ) { if (Final_Array[Count] == Hold ) { controller = 1; } Count++; } if (controller != 1) { Final_Array[x] = Hold; } } cout << endl; cout <<"Unique numbers:" << endl; print_Array (Final_Array,size); } /* FUNCTION BODIES */ /****************************************************************************/ /****************************************************************************/ void print_Array (int Array[], int size) { for (int x = 0; x<size; x++) { cout <<"\t"<< Array[x] ; if (x == 9){cout << endl;} } }
there is a problem, i cant get the final_array to be filled. :/ i dont rly know what i have done wrong