Initialize your variables:
int x = 1; int y = 1;
There are 3
statements for the for loop
: -1. Initialize, 2. Condition, 3. Iteration:increment/decrement
In your case, you did not provide the initialize condition, however, you have the part of condition and incrementation. I do not think your for loop is used in the correct way.
You should swap the part of incrementation with your body like this:
for(; y; y = x++ <= 5;)
printf("%d %d\n", x, y)
First, you check whether the condition is true or not, y
is true or not. Then, you print x
and y
out. Then, the part of incrementation is executed, x++ <= 5
or not. The result is assigned to y
. It does so until your condition is false, y
== false
.
NOTE: For the good programming, you should enclose your body with a curly braces.