This program is supposed to have the user enter in 15 values, put them into an array, and then reverse that array. The output is putting a zero in the fourteenth place and cutting off the last number.
EX)
1 2 3 4...14 15--> 0 15 14...4 3 2
I'm really stuck. Some help would be much appreciated!
The problem in your code is in the loop of backwards() function. The indexes of vector start from 0 and end with inputs.size()-1, so the loop you're looking for would be:
1 2 3 4 5 6 7 8 9
void backwards(vector <int> inputs) {
cout<<"The array in reverse order is: ";
for(int i=inputs.size()-1; i>=0; i--)
{
cout<<inputs[i]<<" ";
}
}
Pay attention to int i= inputs.size()-1 and i>= 0; the last element in vector is inputs[inputs.size()-1] and the first one is inputs[0]