when j will be incremented ? is it before i or after i?
Walk through oPossum's code step by step. Technically, i will be incremented after the loop containing j exits.
But even though i is incremented after j, one should note that in reality what happens is that i counts from 1 to 2, and for each of the values of i, j counts from 1 to 2.
So your values inside the loop will be:
i=1 j=1
i=1 j=2
i=2 j=1
i=2 j=2
when the entire code exits, i will actually be 3 and so will j, since j got incremented to 3 which exited the inner loop, and i incremented to 3 which exited the outer loop.
One should note that this portion of your code:
if (i==j)
continue;
printf ("%d %d\n",i,j);
is functionally equivalent to:
if (i!=j) printf ("%d %d\n",i,j);
The second form is easier to understand is generally considered better form. Avoid using break and continue within a for loop since they can lead to unexpected bugs.