posted 5 years ago
Because the declarations are outside of the for-loop header, not inside.
This:
declares both y and x as long values in the for-loop header, even though "long" is only specified for y, it is implied that x is long as well. You can't have mixed types when you declare multiple loop variables. If you're going to declare a type for the loop variables, it has to be specified for the first variable and it will be applied to any other loop variables you list that haven't already been previously declared.
This does not declare any types for y and x in the for-loop header:
Here, y and x are declared outside of the for-loop and those are the types that will be applied to them. Again, you can use variables of different types as loop variables, you just can't declare different types in the for-loop header.
Try this:
See what happens if you try to do this instead: