Question: Given

```
int x[10];
int y[10];
int n = 10;

```

Version 1

```
int i = 0;
while (i < n)
  y[i] = x[i++];

```

Version 2

```
for (int i = 0; i < n; i++)
  y[i] = x[i]

```

Are the two versions always equivalent? If not, when are they not equivalent?

Answer: 
This line:

```
y[i] = x[i++];

```

is *undefined behaviour*. You cannot use `i` and `i++` within the same statement.

Your Version 2, with the `i++` inside the `for` control statement, is fine.
Good question,
take a look [here](http://assembly.ynh.io/)
you can find a nice c to assembler web compiler
I compared the two versions and there are minor assembly differences in the loop implementation.
the functionality seems exactly the same therefor I conclude both samples are always equivalent.
While case:
![this is the while loop](https://i.stack.imgur.com/faB39.png)
For case:
![this is the for loop](https://i.stack.imgur.com/0lQKf.png)