hey guys. i have a very simple programming assignment. i have a little experience in c++ but the code that im using is not working. the assignment is to use an array to enter 10 numbers and then print them out in reverse order. the following code that i am using is

#include<iostream>
using namespace std;

main()
{
int i, num[10];

for(i=0;i<10;i++)
{
cin>>num;
}
for(i=0;i<10;i--)
{
cout<<num<<" ";
}
system("PAUSE");
}

the for loop works for the cin statement but is not working for the cout. if anyone has answers pls help.

thanks

The loop for the cout statement is backwards for(i = 9; i >= 0; i--)

Thank You so much. I was trying everything. But now I see why it wasnt working. Because at first it was giving me a continuous loop just going and going on and on but i see why now cuz once it reach 0, 0 is always less than 10 so das why. Ok once again thanks and I appreciate it.

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.