Option D is correct.
Four possible cases arise here:
1. x = EVEN, y = EVEN
2. x = ODD, y = ODD
3. x = ODD, y = EVEN
4. x = EVEN, y = ODD
Case 1:
x is even, so else part will be executed.
x = 2x, y = 0, z = 0 (z = x*y = a*b)
Case 2:
x is odd, so if part is executed.
After 1st iteration --> x = no change, y reduces by 1, z increases by 1.x.
After 2nd iteration --> x = no change, y = reduces by 2 from the original value, z increase by 2.x (value of x used before the loop).
Here x doesn't change, so the loop will never execute the else part of the code.
The loop will stop only when y becomes 0. As you can see y decreases by 1 every iteration, so final values will be
x = no change, y becomes 0, z = x added y no. of times (i.e z = x*y = a*b).
Case 3:
Same as case 2 where x is odd, so only if part of the code will be executed for every iteration.
The loop will stop when y becomes 0, so the final values will be
x = no change, y becomes 0, z = x added y no. of times (i.e z = x*y = a*b).
Case 4:
x is even, so for the first iteration, else part will be executed which leads to
x = 2x, y = 1 (odd % 2 = 1), z = 0.
The loop will never end because y > 0 throughout the loop at every iteration.
So for some values of a & b, the loop will never terminate, but if it terminates then z = a*b will hold.