I was wondering if it is possible to dynamically increment in a for-loop in C++. For example, I have the following code:

```
for (int x = 0; x < maxX-1; x ++){
    for (int y = 0; y < maxY-1; y ++){
        for (int z = 0; z < maxZ-1; z++){
             cout << "z = " << z << endl;
        }   
    }
}

```

Which prints out

```
z = 0
z = 1
z = 2
...

```

However, if I were to change the loop to:

```
    amount = 2;
for (int x = 0; x < maxX-1; x ++){
    for (int y = 0; y < maxY-1; y ++){
        for (int z = 0; z < maxZ-amount; z+= amount){
             cout << "z = " << z << endl;
        }   
    }
}

```

Then I get an infinite loop of 

```
z = 0
z = 0
z = 0
z = 0

```

Is it not possible to do this?