Simplifying an Array

Hello,

I'm trying to figure out how to simplify an incredibly long line of code. I'm trying to check whether one number of an array element is larger than the previous one. My raw code for this line is:

 
   if (myArray[0] <= myArray[1] && myArray[1] <= myArray[2] && myArray[2] <= myArray[3] && myArray [3] <= myArray[4] && myArray[4] <= myArray [5] && myArray [5] <= myArray[6] && myArray [6] <= myArray[7] && myArray[7] <= myArray[8] && myArray[8] <= myArray[9])


As you can see, it's very long, not very efficient, and hard to read. I'm trying to get this on maybe 1-2 lines, if possible. Any help would be much appreciated. Thanks in advanced for your help.
You could use a loop

The thing is though, I don't know how to make a loop that would increase the elements of an Array, then compare them. The closest I've come is:

1
2
3
{
    for (int x=0; x < length; x ++)
}


And then I'm pretty much stuck. I don't know how to increase the increments of an array, then put them into a loop. I've tried everything from anArray[x+1] to anArray[x]+1 to anArray[++] and I just can't figure it out.
Maybe something like
1
2
3
4
5
6
7
8
9
bool condition = true;
for (int i = 0; i < 9; ++i)
    if (myArray[i] > myArray[i+1])
    {
        condition = false;
        break;
    }
if (condition)
    // ... 

Make sure you understand why this works before you copy/paste anything.
You might run into the same (or similar) problem in the future!
I appreciate your help Long, but it's not doing what I want it to. I'm still messing around with things in my code. I am very happy that you showed me that myArray[x+1] is indeed a valid operation in C++. What I'm getting from this code is:

When the parameters of i are less than 9, increase the base parameters until it reaches 8. Then compare each increment of the element to the one next in line?
Topic archived. No new replies allowed.