Im making a program with lots of repeating code, so I decided to take all that repeating code and change it into an array. problem is, I've never worked with arrays before. I tried to look up alot of tutorials, and I understand it more now, but not enough to do what I want.

I need an array that will let the user enter multiple strings of numbers (like entering 13, then entering 45, ect.) and then I need a part were all the numbers they entered to be displayed on the screen. I also need a way to refer to the numbers individually (like "your first number was..." or "your second # was...")

can anyone show me how to do this?

The two tasks are related. Each element of the array is an instance of that type and can be acessed using an index within the [] operator.

const int MAX = 3
int example[MAX];

for(int i = 0; i < MAX; ++i)
{
  cin >> example[i];
}

for(int j = 0; j < MAX; ++j)
{
   cout << "element # " << j + 1 << " is " << example[j] << endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.