Help with Reversing output of an array.

For a school assignment, my professor gave me this:

Write a program that will accept 10 numbers as input. When all the numbers have been input, output the list of numbers in reverse order.

This is the code I have come up with so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cstdlib>


using namespace std;

int main()
{
	int input[10];
	input[0] = 0;
	input [1] =0;
	input [2] =0;
	input [3] =0;
	input [4] =0;
	input [5] =0;
	input [6] =0;
	input [7] =0;
	input [8] =0;
	input [9] =0;
	
	
	for(int i=0; i<10; i++)
	{
		cout<<"Please enter a number."<<endl;
		cin>>input[i];
	}
	cout<<"The numbers entered in reverse order are:"<<endl;
	cout<<endl;
	
	for (int w=10; w>0; w--)
	{
		cout<<input[w]<<endl;
		cout<<endl;
	}
}


Everything works fine, except when it outputs the input in reverse order, the first number output is way off and the last number that should be output never is. What am I doing wrong?

Also, in this course I am NOT allowed to use functions of any kind.
Make sure the index w in the correct range.
Thank you. I knew I was missing something small and basic.
Topic archived. No new replies allowed.