[Solved] Can you explain the output of the following C code?


This is simple. You only need good understanding of continue statement.

  • Loop 1 : x = 3 , y = 1 (after x– and y++)
  • Loop 2 : x = 2 , y = 2 (So you hit the continue and goes to the top of the loop again
  • Loop 3 : x = 1 , y = 3
  • Loop 4 : x = 0 , y = 4 (The loop checks till x>=0)
  • Loop 5 : x = -1, y = 5 (Loop terminates)

4

solved Can you explain the output of the following C code?