Hey guys, I'm learning the ins and outs of arrays now. I understand that the index numbering starts at 0. So in my case index 0 in my code produces a value of 1. My question is, how can I manipulate my code in my for loop for it to display this?
1: Array Location is 1
2: Array Location is 3
3: Array Location is 5
4: Array Location is 7
5: Array Location is 9
I messed around a bit with changing my for loop but I couldn't produce the result I wanted. Thanks for the help. :-)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int main ()
{
int ARR [5] = {1, 3, 5, 7, 9};
int x;
cout << "Display first value in array: " << ARR [0] << endl;
cout << "Now Display last value in array: " << ARR [4] << endl;
for (x = 0; x < 5; x++)
{
cout << x << ": Array Location" << " is " << ARR [x] << endl;
}
system("pause");
return 0;
}