# Thread: Printing an array in reverse order!

1. ## Printing an array in reverse order!

I'm pretty new to arrays, and I'm having a slight problem printing one of my arrays in reverse:
Code:
```#include <stdio.h>

int main(void)

{	int i;
int firstarray[7] = {4, 9, -3, 0, 2, 7, 51};
int secondarray[5] = {34, -6, 5, 15, -21};

printf("The First Array is: ");
{
for(i=0;i<7;i++)
printf("%d ",firstarray[i]);}
printf("\n");

printf("The Second Array is: ");
{
for(i=0;i<5;i++)
printf("%d ", secondarray[i]);}
printf("\n");

printf("The First Array in reverse order is: ");
{
for(i=0;i>=7;i--)
printf("%d ", firstarray[i]);
printf("\n");
}

}```
The array in reverse doesnt print anything at all. Any idea what I'm missing?

2. Because your condition is wrong.

Code:
`for(i=0;i>=7;i--)`
notice anything wrong with that?

If 'i' is set to zero and your condition is that it should be GREATER than or equal to '7' how will it ever run?

should be:

Code:
`for(i=6;i>=0;i--)`
hth,

-Feen

3. Originally Posted by Feengur

Code:
`for(i=0;i>=7;i--)`
notice anything wrong with that?

If 'i' is set to zero and your condition is that it should be GREATER than or equal to '7' how will it ever run?

should be:

Code:
`for(i=6;i>=0;i--)`
hth,

-Feen
lmao, wow I feel like an idiot. XD Thanks Feen.

4. no problem. It happens all the time!