i need the whole c++ programming code for this because am making mistakes in it everywhere i think so pls help me..................

(printing distinct numbers) write a program that reads ten numbers and displays distinct numbers
(i.e., if a number appears multiple times, it is display only once). (hint: read a number and store it to an array if it is new. if the number is already in the array, discard it. after the input, the array contains the distinct numbers.)...............

this is what i got i dont really get or know how to do the rest...... pls help

#include <iostream>

using namespace std;

int main ()

{
    int Tnumbers[10];

    for (int t = 0; t < 10; t++)

    {
        cout <<" Enter a number:";

        cin >> Tnumbers [t];




    }

    for (int t = 0; t < 10; t++)

    {
        cout << Tnumbers [t] << endl << endl;
    }



    return 0;
}

Did your instructor explain what "read" means? Does it mean read the numbers from a text file, or get the numbers from the keyboard?

On line 15 you should read a number into a simple integer variable instead of directly into the array. The reason is that after getting the number the program has to search the array to see if the number is already in it. If it is, then just go on to the next number. If the number is not in the array, then add it.

You search an array in a simple loop. If the loop counter is variable named i, then check the ith value in the array against the number just entered.

i think i kind of understand what your saying but i dont really know how to implement all of that..... am not really great with array programming as yet and my teacher is not much help all of what i learn is out of book by myself my teacher doesnt really teaches well...

Do it just a small piece at a time -- don't get overwhelmed by the complexity of it all.

First, change line 15 to get the number into a simple variable instead of into the array.

After that is done, create another loop to search the array for the value entered on line 15. When you get that finished, post the code you have written so we can see it.

ok will try and get back to you and thanks for your help and your time by the way........

This article has been dead for over six months. Start a new discussion instead.