When continue statement is executed, i+=1; is not executed in the second program. That's why you are getting different result.