int z =10;
for (int i=0; i<z; i+=2)
{
z--;
cout << "i = " << i << " z = " << z << '\n';
}
When there's something that seems puzzling, often getting more information can help to stabilise your thinking, so instead of a vague sense of mystery, there are solid facts to look at.
y[i] is meaningless unless you specify the value of i.
But in any case, it won't be 7700, it has to be one of these: {7,5,7,6,0,2,0,6,9,2}; edit: I may have misunderstood your meaning.
One step at a time
consider this:
1 2 3 4 5
for (int i=0; i<z; i+=2)
{
z--;
cout << "i - " << i << " y[i] = " << y[i] << '\n';
}
Now you know the individual, separate values of y[i] you can put that into its original context.
If it helps, look at this:
1 2 3 4 5 6 7 8
for (int i=0; i<z; i+=2)
{
z--;
int index = y[i];
cout << "index = " << index << " y[index] = " << y[index] << '\n';
}
okay that was a much clearer example on whats going on. i still dont understand why i =0,2,4,6 and not 0,2,4,6,8 since 8 is smaller than 10? same for z