Inside a for loop, what does the continue statement do?
Correct answer
C. Skips the rest of the body and runs the update step
14 views
C. Skips the rest of the body and runs the update step
14 views
continue abandons the remaining statements of the current iteration and jumps to the loop's update expression, after which the condition is tested again. In a while loop it jumps straight to the condition, which can cause an infinite loop if the counter is updated below the continue. break is the contrasting statement, since it leaves the loop entirely instead of starting the next pass.
Asked in: NTS, PPSC IT, Campus Interviews
Not sure why the answer is C? Ask here and get an explanation.