if ((i++)%2 == 1) continue;
This is the heart of the code. continue
will make the compiler skip rest of the lines in the loop, and go straight back to checking the loop condition again.
Post increment will increment i after checking the condition.
When i = 0, we won't hit continue
. So, add 1 (and not 0, because post-increment)
When i = 1, we hit continue
. So skip rest of the lines.
When i = 2, add 3.
When i = 3, we hit continue
.
When i = 4, add 5.
Break out of while loop now. Because i = 5.
So finally; $a = -3 + 1 + 3 + 5 = 6$. And $b = -6 + 1 + 3 + 5 = 3$
Swap doesn't do anything to the values inside a and b, so a and b stay intact.
a = 6, b = 3
Option D.
Now, when printab() is called the second time, i = 5. But in the immediate next line, i = 0. So, while loop will run the same.
$a = 6 + 1 + 3 + 5 = 15$
$b = 3 + 1 + 3 + 5 = 12$